我想重定向WWW网址非www为我的论坛。我的论坛安装在一个名为论坛的子目录。在我的根目录下我有没有安装Word preSS。单词preSS在我的根目录下的.htaccess重定向工作正常,但我无法得到它的工作为我的论坛。
I'm trying to redirect www URLs to non-www for my forum. My forum is installed in a subdirectory called "forum". In my root directory I've got WordPress installed. For the WordPress in my root directory the .htaccess redirection works fine, but I'm having trouble get it working for my forum.
我试了几个,我发现在谷歌的搜索规则,但他们没有工作。
I've tried a couple of rules that I found in Google search but they didn't work.
我还检查了这个话题通用htaccess的重定向WWW到非www
但对我来说的htaccess的文件是一个子目录,而不是根。
but in my case the htaccess file is in a subdirectory and not in the root.
也许我做的事情错了,所以这是我整个.htaccess文件:
Probably I'm doing something wrong so here is my entire .htaccess file:
# Mod_security can interfere with uploading of content such as attachments. If you # cannot attach files, remove the "#" from the lines below. #<IfModule mod_security.c> # SecFilterEngine Off # SecFilterScanPOST Off #</IfModule> ErrorDocument 401 default ErrorDocument 403 default ErrorDocument 404 default ErrorDocument 405 default ErrorDocument 406 default ErrorDocument 500 default ErrorDocument 501 default ErrorDocument 503 default <IfModule mod_rewrite.c> RewriteEngine On # If you are having problems with the rewrite rules, remove the "#" from the # line that begins "RewriteBase" below. You will also have to change the path # of the rewrite to reflect the path to your XenForo installation. RewriteBase /forum RewriteCond %{HTTP_HOST} www.example$ RewriteRule ^(.*)$ example/forum$1 [R=301,L] # This line may be needed to enable WebDAV editing with PHP as a CGI. #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L] RewriteRule ^.*$ index.php [NC,L] </IfModule>
任何帮助是AP preciated。 谢谢
Any help is appreciated. Thanks
推荐答案您需要更换这一个你的 WWW 清除规则:
You need to replace your www removal rule with this one:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ %1%{REQUEST_URI} [NE,R=301,L]请确保在新的浏览器来测试以避免旧的缓存。
Make sure to test this in a new browser to avoid old cache.
更多推荐
WWW重定向到非www
发布评论