Removing WWW Instead of Adding it

Topics: Developer Forum, User Forum
Sep 6, 2009 at 6:20 PM


I found RegExes hard to grasp and couldn't write this on my own, could someone help me out? My website is seen by search engines as 2 different websites: and and I would like the later redirected (301 moved permanently) to the former. My problem is Im using a WordPress on a Windows Server and to get permalinks to work I used the following:


RewriteRule ^/(?!index.php)(?!wp)([^\.]*)$ /index.php/$1 [I]
RewriteRule ^/downloads/(.*)$ /wp-content/plugins/download-monitor/download.php?id=$1 [I]


Could the 301 redirect be added to this to make it work without breaking the current links.

Thank you.

Sep 6, 2009 at 10:10 PM

ssomething isn't making sense.  if you have and and you want the latter to redirect to the former, you want to ADD www instead of removing it.  This is the opposite of your title?

To redirect based on hostname you need a RewriteCond.  There is an example of exactly what you ask for in the documentation

IterationLimit 10
MaxMatchCount 10
RewriteEngine ON
StatusUrl /iirfStatus
RewriteLog c:\logs\iirf
RewriteLogLevel 3

# Add www as a prefix: 
# With a request like, redirect (HTTP 301)
# the request to

RewriteCond  %{HTTP_HOST}  ^domain\.com$
RedirectRule ^/(.*)$       http:/$1         [R=301]

Sep 6, 2009 at 10:30 PM

Thank you Cheeso, that worked perfectly. Sorry about the title (I found out that with the www is better but forgot to modify the title) and not reading the documentation too.

And by the way, I think IIRF has the only discussion board with nearly all the questions answered.