【发布时间】:2016-04-15 15:09:31
【问题描述】:
我在我的域的子文件夹 www.example.com/blog 中有一个 Wordpressinstallation。它有自己的 404 页面,不幸的是,如果在我的主网站上找不到页面,它也会显示。
我想要一个404 重定向我的主网站和子文件夹中我博客的 Wordpress 重定向。
这是我到现在为止的代码。但是第二个覆盖了第一个。如何使 wordpress 重定向仅适用于子文件夹?
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC]
RewriteRule ^(.*) http://www.example.com/$1 [R=301,NE,L]
ErrorDocument 404 /notfound/404.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
【问题讨论】:
标签: php wordpress .htaccess redirect