htaccess的永久重定向到www [英] .htaccess permanent redirect to www

查看:114
本文介绍了htaccess的永久重定向到www的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个词preSS安装目录未重定向的URL不是以WWW。

例: http://example.com/dir/ 不会发送到的 http://www.example.com/dir/ ,而不是去的 http://example.com/

我要如何改变的.htaccess下面总是重定向到网页或者使用WWW或不?

 #BEGIN字preSS
RewriteEngine叙述上

的RewriteBase /
重写规则^指数\ .PHP $  -  [L]

#上传的文件
重写规则^([_ 0-9A-ZA-Z  - ] + /)?文件/(.+)WP-包括/ MS-files.php文件= $ 2 [L]

#添加斜线到/可湿性粉剂管理员
重写规则^([_ 0-9A-ZA-Z  - ] + /)?WP-ADMIN $ $ 1WP管理员/ [R = 301,L]

的RewriteCond%{} REQUEST_FILENAME -f [OR]
的RewriteCond%{} REQUEST_FILENAME -d
重写规则^  -  [L]
重写规则^([_ 0-9A-ZA-Z  - ] + /)?(WP-(内容|管理|包含)。*)$ 2 [L]
重写规则^([_ 0-9A-ZA-Z  - ] + /)?(。* \ PHP)$ $ 2 [L]
重写规则。的index.php [L]

#结束字preSS
 

解决方案

更​​多类似的问题 http://webmasters.stackexchange.com

好吧,无论如何,如果你正在使用的cPanel,你可以做一个通配符从重定向重定向在域名类别。

但如果不是,试试这个:

 选项+了FollowSymLinks
RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^ example.com [NC]
重写规则^(。*)$ http://www.example.com/$1 [R = 301,NC]
 

I have a wordpress instalation that is not redirecting urls not starting with www.

Example: http://example.com/dir/ doesn't send to http://www.example.com/dir/ instead goes to http://example.com/

How do I change the .htaccess below to always redirect to the page either using www or not?

# 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).*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

# END WordPress

解决方案

More like a question for http://webmasters.stackexchange.com

Well anyway, if you are using cPanel, you can do a wildcard redirect from Redirects under Domains category.

But if not, try this:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com[nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]

这篇关于htaccess的永久重定向到www的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆