我正在创建一个PHP控制器,用于在我的域上进行测试。默认情况下,域完全在Wordpress上,我在设置由PHP控制器控制的文件夹testing1
时遇到问题。这是我的.htaccess文件中的代码:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
RewriteRule ^testing1/(.*)$ ./testing1/controller.php
</IfModule>
# END WordPress
当我转到mydomain.com/testing1/
时,我得到一个内部服务器错误。感谢您的帮助。谢谢
去掉用于指向当前目录的./
。
RewriteRule ^testing1/(.*)$ testing1/controller.php
我让它工作。
重写规则按顺序执行。如果其中一个匹配,则忽略其余部分。因此,结果可能看起来像这样(只是RewriteRules):
RewriteRule ^testing1/(.*)$ /testing1/controller.php
RewriteRule . /index.php
第二条规则确实意味着,当你只键入一个字符(无论是什么)时,你会被引导到index.php。不过我不知道这是否是你想要的行为。