1

我正在使用以下代码...

#Fix Rewrite
Options -Multiviews

# Mod Rewrite
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)?$ index.php?q=$1 [L]

变成www.website.com/index.php?q=Keyword_www.website.com/Keyword

效果很好……但是……

我也(在同一目录中)有一个名为的文件spec.php,它接受GET一个eid.

我还需要有一个规则可以变成www.website.com/spec.php?eid=00000www.website.com/00000www.website.com/spec/00000实际移动spec.php到子目录中。

任何帮助将不胜感激,我的眼睛被谷歌烧伤了。我发现一些做类似的事情,但是当我试图将它与我的情况相匹配时,我遇到了问题。

4

1 回答 1

0

所以这条线在这里

RewriteRule ^(.*)?$ index.php?q=$1 [L]

是匹配一切,如果你想有website.com/Keyword工作和website.com/spec/0000工作那么你需要添加另一个条件

我认为这会奏效

RewriteRule ^/spec/(.+)$ /spec.php?eid=$1 [L]
RewriteRule ^(.*)?$ /index.php?q=$1 [L]

这是什么话?

First part is a regular expression, second part is the URL to map it to and the last part is the flags. In this instance we put the /spec/ condition first so that it is hit first as the second condition will match everything else and then make sure the [L] flag is set as that tells mod_rewrite to stop if the current condition matches.

于 2013-03-06T02:02:28.793 回答