一般.htaccess重写问题

时间:2013-12-18 05:35:35

标签: .htaccess mod-rewrite

我有一个通过Pagoda Box托管的网站。我有一个关于编写.htacess文件以强制域名的www部分的问题。我试图让域强制www并包含它。

域名目前没有使用www部分,即使.htaccess文件似乎强制它:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain.gopagoda.com$ [OR]
RewriteCond %{HTTP_HOST} ^wwww.domain.gopagoda.com$
RewriteRule (.*)$ http://www.domain.com/$1 [R=301,L]
Redirect 301    /copy_index.html    http://www.domain.com
# BEGIN WordPress
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>

我是.htaccess文件编辑的新手,并查看了许多教程,但我没有看到任何使用此语法如上所述。四个ws(wwww)?

任何帮助将不胜感激!非常感谢!

最佳, 摩根

1 个答案:

答案 0 :(得分:1)

检查您的WP永久链接设置,确保您的网站和博客地址中都包含www

然后将规则更改为:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(wwww\.)?domain\.gopagoda\.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L,NE]

RewriteRule ^copy_index\.html$ / [R=301,L,NC]

# BEGIN WordPress
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress