好的,所以我的.htaccess位于http://example.com/forums/
RewriteEngine On
RewriteRule ^threads/([^/]+)/([^/]+)$ forums-threads.php?code=$1&pn=$2 [QSA]
RewriteRule ^threads/([^/]+)$ forums-threads.php?code=$1 [QSA]
RewriteRule ^new-thread/([^/]+)$ forums-new-thread.php?code=$1 [QSA]
RewriteRule ^new-post/([^/]+)$ forums-new-post.php?code=$1 [QSA]
RewriteRule ^([^/]+)/([^/]+)$ index.php?code=$1&pn=$2 [QSA]
RewriteRule ^([^/]+)$ index.php?code=$1 [QSA]
现在的问题是,当我转到一个新的线程URL like this example时,它转到索引页面,输出的$_GET
变量是
Array ( [code] => eUjJP-Announcements [pn] => eUjJP-Announcements )
我想知道如何解决此问题,以及上述.htaccess
代码中是否还有其他问题需要纠正。
答案 0 :(得分:0)
这种情况正在发生,因为下面的后续规则仍在执行,因为您没有任何其他条件可以阻止它。
用以下代码替换您的代码:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /forums/
RewriteRule \.php$ - [L]
RewriteRule ^threads/([^/]+)/([^/]+)$ forums-threads.php?code=$1&pn=$2 [QSA,L]
RewriteRule ^threads/([^/]+)$ forums-threads.php?code=$1 [QSA,L]
RewriteRule ^new-thread/([^/]+)$ forums-new-thread.php?code=$1 [QSA,L]
RewriteRule ^new-post/([^/]+)$ forums-new-post.php?code=$1 [QSA,L]
RewriteRule ^([^/]+)/([^/]+)$ index.php?code=$1&pn=$2 [QSA,L]
RewriteRule ^([^/]+)$ index.php?code=$1 [QSA,L]