我在域和目录中安装了Wordpress,我有一个用PHP + MySQL开发的站点完全独立于wordpress。它独自工作。这个站点是一个后台,所以它安装在/ backoffice /目录下。
后台的一个目录我有另一个目录,我希望它可以使用友好的URL。
在我的.htaccess中,我有以下规则:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^backoffice/edit_user/([^/\.]+)/?$ /backoffice/edit_user/index.php?o=$1 [L,NC,QSA]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !=/server-status
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^login/?$ wp-login.php [QSA,L]
RewriteRule ^postpass/?$ wp-login.php?action=postpass [QSA,L]
RewriteRule ^logout/?$ wp-login.php?action=logout [QSA,L]
RewriteRule ^lostpassword/?$ wp-login.php?action=lostpassword [QSA,L]
RewriteRule ^retrievepassword/?$ wp-login.php?action=retrievepassword [QSA,L]
RewriteRule ^resetpass/?$ wp-login.php?action=resetpass [QSA,L]
RewriteRule ^rp/?$ wp-login.php?action=rp [QSA,L]
RewriteRule ^register/?$ wp-login.php?action=register [QSA,L]
当调用这样的网址时:mydomain.com/backoffice/edit_user/joseantonio会出现404页面。
怎么了?
提前致谢。
答案 0 :(得分:6)
正如this answer中所述 - 您可以调试 Apache 重写。打开虚拟主机 OR 服务器配置中的RewriteLog
:
RewriteEngine On
RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 3
然后,您将看到使重定向404的规则。
答案 1 :(得分:2)
最后,我找到了解决方案:
以下是与wordpress结合使用的代码:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
**RewriteRule ^backoffice/edit_user/([^/\.]+)/?$ /backoffice/edit_user/index.php?o=$1 [L,NC,QSA]**
RewriteCond %{REQUEST_URI} !=/server-status
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^login/?$ wp-login.php [QSA,L]
RewriteRule ^postpass/?$ wp-login.php?action=postpass [QSA,L]
RewriteRule ^logout/?$ wp-login.php?action=logout [QSA,L]
RewriteRule ^lostpassword/?$ wp-login.php?action=lostpassword [QSA,L]
RewriteRule ^retrievepassword/?$ wp-login.php?action=retrievepassword [QSA,L]
RewriteRule ^resetpass/?$ wp-login.php?action=resetpass [QSA,L]
RewriteRule ^rp/?$ wp-login.php?action=rp [QSA,L]
RewriteRule ^register/?$ wp-login.php?action=register [QSA,L]
正如你所看到的,我在index.php规则之后更改了我的规则的位置,工作正常,在任何其他位置,它都无法工作。
答案 2 :(得分:1)
您可以尝试在/ backoffice /文件夹中使用自己的.htaccess
RewriteBase /backoffice/
# all the backofice rules