防止子页面重定向到根URI

时间:2011-09-17 23:14:46

标签: wordpress .htaccess

我在运行WordPress 3.1.4 Multisite的网站上遇到了一个小问题但很烦人。

导航到没有“http:// www”的子页面的URI,例如“abetterworldbydesign.com/2011-conference/”会导致重定向到根“http://www.abetterworldbydesign.com”。

意图是“abetterworldbydesign.com/2011-conference/”重定向到“http://www.abetterworldbydesign.com/2011-conference/”。

下面的

.htaccess文件(它是specific stuff for WordPress Multisite)。

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END WordPress

1 个答案:

答案 0 :(得分:1)

尝试添加此

RewriteCond %{HTTP_HOST} ^abetterworldbydesign.com
RewriteRule ^(.*)$ http://www.abetterworldbydesign.com/$1 [R=301,L]

位于最顶层,就在RewriteEngine On之后。