Apply rule to all domains
2 posts
• Page 1 of 1
- brienmalone
- Posts: 1
- Joined: 06 Mar 2013, 17:04
Apply rule to all domains
I need to remove the "www." from all domains. This code works fine for an individual domain:
Is there a way to rewrite this so it applies to all domains? I want to do something like this:
... but the $1 wont reference the (.+) in the rewritecond.
I have 20 domains and I would rather not run a separate rule for each one when they all do the same thing!
- Code: Select all
RewriteCond %{HTTP:Host} ^www\.subdomain\.domain\.edu$ [NC]
RewriteRule .? http://subdomain.domain.edu$1 [R=301,L]
Is there a way to rewrite this so it applies to all domains? I want to do something like this:
- Code: Select all
RewriteCond %{HTTP:Host} ^www\.(.+)$ [NC]
RewriteRule .? http://$1$2 [R=301,L]
... but the $1 wont reference the (.+) in the rewritecond.
I have 20 domains and I would rather not run a separate rule for each one when they all do the same thing!
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Apply rule to all domains
Hello,
Lets try using the following rule:
This rule is supposed to cover domains that start with "www" and are followed by three parts separated by '.'
So it will match both "www.subdomain.domain.com" and "www.domain.com.au", so you'd need to do corresponding adjustments suitable for your domain system.
Regards
Andrew
Lets try using the following rule:
- Code: Select all
RewriteCond %{HTTP:Host} ^www\.([^.]+\.[^.]+\.[^.]+)$ [NC]
RewriteCond %{REQUEST_URI} (.*)
RewriteRule .? http://%1%2 [R=301,L]
This rule is supposed to cover domains that start with "www" and are followed by three parts separated by '.'
So it will match both "www.subdomain.domain.com" and "www.domain.com.au", so you'd need to do corresponding adjustments suitable for your domain system.
Regards
Andrew
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests