简体   繁体   English

RewriteRule和RewriteCond无法正常工作

[英]RewriteRule and RewriteCond not working

I am tring to retwite: 我想转发:

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

to

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

and similarly: 并类似地:

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

to

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

Using following rules: 使用以下规则:

<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>

But it is not working properly, I think it is treating 但它不能正常工作,我认为它正在治疗

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

as

http://example.com/industry.php

Need help to resolve it. 需要帮助来解决它。

Thank you 谢谢

You don't need the RewriteCond statements. 您不需要RewriteCond语句。

Try this (without the RewriteCond): 试试看(不使用RewriteCond):

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

Or, more simply, this: 或者,更简单地说,这是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM