您好,我有一个 WordPress 网站,我想在根目录中创建一个独立于 WordPress 的自定义文件夹。我必须使用什么重写规则才能访问该文件夹? 我已经放了
RewriteRule ^clients? /clients/index.php [L]
当前 htaccess 文件
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^clients? /clients/index.php [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
当我访问该文件夹时,我收到内部服务器错误 500
你必须有一个无限的重写循环,请参阅这个答案。试试这个:
...
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^clients? /clients/index.php [L]
...
为了完美,您可能还想添加
QSA
和 NC
标志。
即使这是一个非常古老的问题。我想为那些像我一样的菜鸟回答 .htaccess 规则。
这应该是您正在寻找您的情况的规则,并且您将其放在 .htaccess 文件中的位置必须是正确的,因此无需更改其位置。
RewriteRule ^clients/(.*) clients/index.php [L]