admin管理员组文章数量:1130349
How to set htaccess to such examples in a Wordpress Multisite:
- domain - redirect to - www.domain
- sudomain.domain - no redirect
I have a Error 310 (net::ERR_TOO_MANY_REDIRECTS) when my .htaccess file looks like this:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]
How to set htaccess to such examples in a Wordpress Multisite:
- domain - redirect to - www.domain
- sudomain.domain - no redirect
I have a Error 310 (net::ERR_TOO_MANY_REDIRECTS) when my .htaccess file looks like this:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]
Share
Improve this question
edited Mar 15, 2013 at 20:03
brasofilo
22.2k8 gold badges70 silver badges270 bronze badges
asked Mar 15, 2013 at 19:42
Alex AungAlex Aung
1352 silver badges8 bronze badges
3 Answers
Reset to default 2Try:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^/(.*) http://www.%{HTTP_HOST}/$1 [L,R=301]
I think you only need to ask explicit for %{HTTP_HOST} to be domain. All implicit conditions like »does %{HTTP_HOST} NOT start with www« will effect all subdomains too. So this should work for your case
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\$
RewriteRule ^(.*)$ http://www.domain/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]
Make sure, that the constant DOMAIN_CURRENT_SITE and the domain attribute (in network settings) of your root blog is set to www.domain. The NOBLOGREDIRECT constant might also be helpful for your purposes.
You don't need to add any codes in htaccess file. There is very easy solution to this. In the 'Network Admin -> Settings -> Domains' page, add both the www. and non-www. versions of the domain, select the box of 'primary' for if you want to mainly use for www. or non-www. and both will be assigned to the website.
How to set htaccess to such examples in a Wordpress Multisite:
- domain - redirect to - www.domain
- sudomain.domain - no redirect
I have a Error 310 (net::ERR_TOO_MANY_REDIRECTS) when my .htaccess file looks like this:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]
How to set htaccess to such examples in a Wordpress Multisite:
- domain - redirect to - www.domain
- sudomain.domain - no redirect
I have a Error 310 (net::ERR_TOO_MANY_REDIRECTS) when my .htaccess file looks like this:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]
Share
Improve this question
edited Mar 15, 2013 at 20:03
brasofilo
22.2k8 gold badges70 silver badges270 bronze badges
asked Mar 15, 2013 at 19:42
Alex AungAlex Aung
1352 silver badges8 bronze badges
3 Answers
Reset to default 2Try:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^/(.*) http://www.%{HTTP_HOST}/$1 [L,R=301]
I think you only need to ask explicit for %{HTTP_HOST} to be domain. All implicit conditions like »does %{HTTP_HOST} NOT start with www« will effect all subdomains too. So this should work for your case
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\$
RewriteRule ^(.*)$ http://www.domain/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]
Make sure, that the constant DOMAIN_CURRENT_SITE and the domain attribute (in network settings) of your root blog is set to www.domain. The NOBLOGREDIRECT constant might also be helpful for your purposes.
You don't need to add any codes in htaccess file. There is very easy solution to this. In the 'Network Admin -> Settings -> Domains' page, add both the www. and non-www. versions of the domain, select the box of 'primary' for if you want to mainly use for www. or non-www. and both will be assigned to the website.
本文标签: multisiteRedirecting non www to www ONLY for domainsubdomain without www
版权声明:本文标题:multisite - Redirecting non www to www ONLY for domain, subdomain without www 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749024816a2304936.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论