【问题标题】:RewriteRule and RewriteCond not workingRewriteRule 和 RewriteCond 不起作用
【发布时间】:2013-08-09 16:57:07
【问题描述】:

我想转发:

http://example.com/industry/fn/bpo-jobs

http://example.com/industry.php?fn=bpoobs

同样:

http://example.com/industry/cat/obs

http://example.com/industry.php?cat=obs

使用以下规则:

<IfModule mod_rewrite.c> 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]+)/$ $1.php 

RewriteCond %{QUERY_STRING} (^|&)fn=(.*)(&|$) 
RewriteRule ^industry/fn/(\w+)$ industry.php?fn=$1 [L]

RewriteCond %{QUERY_STRING} (^|&)cat=(.*)(&|$)
RewriteRule ^industry/cat/(\w+)$ industry.php?cat=$1 [L]

</IfModule>

但它不能正常工作,我认为它正在治疗

 http://example.com/industry/fn/bpo-jobs

作为

http://example.com/industry.php

需要帮助来解决它。

谢谢

【问题讨论】:

    标签: php .htaccess mod-rewrite apache2


    【解决方案1】:

    您不需要 RewriteCond 语句。

    试试这个(没有 RewriteCond):

    RewriteRule ^industry/fn/(\w+)$ industry.php?fn=$1 [L]
    RewriteRule ^industry/cat/(\w+)$ industry.php?cat=$1 [L]
    

    或者,更简单地说,这个:

    RewriteRule ^industry/(cat|fn)/(\w+)$ industry.php?$1=$2 [L]
    

    【讨论】:

      猜你喜欢
      • 2015-01-27
      • 1970-01-01
      • 1970-01-01
      • 2010-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-29
      相关资源
      最近更新 更多