RewriteRule和RewriteCond无法正常工作

时间:2013-08-09 07:50:03

标签: php .htaccess mod-rewrite apache2

我想再见一次:

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

需要帮助来解决它。

谢谢

1 个答案:

答案 0 :(得分:0)

您不需要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]
相关问题