简体   繁体   中英

Redirecting non-www subfolder domain to www on wordpress multisite

I currently have a multisite built in wordpress. The domain is set up to be:

http://www.domain.com

The microsites are set up and built out as:

http://www.domain.com/location-name 

My issues are with the non-www domains. If you go to

http://domain.com/location-name/ or http://domain.com/location-name/about 

it redirects to http://www.domain.com

I need it to redirect to http://www.domain.com/location-name/ or http://www.domain.com/location-name/about

You can use this to force www using your .htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Make sure you clear your cache before testing this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM