Past Subdomains Point to Actual Domain

Discuss practical ways rearrange URLs using mod_rewrite.

Past Subdomains Point to Actual Domain

Postby romans1423 » Thu Mar 17, 2005 4:44 pm

I'm having a problem in that there are still certain places online (search engines, for example) which still have listed as valid domains old subdomains that I no longer have setup anymore... aaa.domain.com, bbb.domain.com, etc. When accessing my site via those domains, the regular www.domain.com shows up. Since there is no error, those pages will be indexed indefinitely, most likely, though they shouldn't even exist anymore.

Is there a way to setup a rewrite rule which would check to make sure that the "subdomain" used is www and only www? If another sub is used, I'd like the URL redirected to the www, merrily on its way.

If possible, could it be flagged "permanently moved" or whatever also? That might make search engines update their index, I hope.

Here are my current rules:

Code: Select all
RewriteEngine On
## Disable viewing of .htaccess and config files.
RewriteRule ^\.htaccess$ - [F]
RewriteRule ^config\.php$ - [F]

## No "www." is a bad thing.
RewriteCond %{HTTP_HOST} ^beckman-ministries\.com
RewriteRule ^(.*)$ http://www.beckman-ministries.com/$1 [R=permanent,L]


Whatever fix there is for my issue cannot interfere with what I'm already doing here.

Any advice or solutions would be much appreciated.
romans1423
 
Posts: 2
Joined: Thu Mar 17, 2005 4:38 pm

Postby Caterham » Fri Mar 18, 2005 2:07 am

Is there a way to setup a rewrite rule which would check to make sure that the "subdomain" used is www and only www? If another sub is used, I'd like the URL redirected to the www, merrily on its way.
Yes:
Code: Select all
RewriteEngine On
## Disable viewing of .htaccess and config files.
RewriteRule ^\.htaccess$ - [F]
RewriteRule ^config\.php$ - [F]

## No "www." is a bad thing.
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.beckman-ministries\.com
RewriteRule ^(.*)$ http://www.beckman-ministries.com/$1 [R=permanent,L]


Bob
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby romans1423 » Fri Mar 18, 2005 9:44 am

Works as expected. Thanks so much!
romans1423
 
Posts: 2
Joined: Thu Mar 17, 2005 4:38 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 21 guests

cron