WWW重定向到非www

编程入门 行业动态 更新时间:2024-10-25 23:27:01
本文介绍了WWW重定向到非www的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想重定向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

本文发布于:2023-07-16 03:45:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117497.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   WWW   www

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!