WordPress的重写规则是这样的:
RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]
现在我想添加一个新的规则,将提供的URL /testing相同的内容作为根页面,但没有做一个实际的redirect。
我努力了:
RewriteRule ^test/$ /index.php [PT]
但似乎给testing作为index.php的参数,因为我得到一个页面未find错误。
你的新规则没有任何问题。 你正在尝试访问“whatever.com/test/”,或者你想要做“whatever.com/test/whatever”吗?
您拥有的规则只能匹配“whatever.com/test/”,而不匹配“whatever.com/test/index.html”。
如果你想要做所有的事情,那就把它改成:
RewriteRule ^test/$ /index.php [PT] RewriteRule ^test/.*$ /index.php [PT]