Click here to Skip to main content
15,879,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want my site to be automatically redirected from to

For this Purpose I have used the following code in .htaccess file

RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)$1 [L,R]

But it is not working and I am not gonna find any problem in this code.
Can Any one Point out the problem.

Note: I have code this code from here[^]
Ed Nutting 28-Jan-12 6:05am    
Have you bothered changing to your site's url? If you don't then it very obviously won't work....
rashidfarooq 2-Feb-12 1:38am    
Yes, Of course, I am not so stupid.
Ed Nutting 3-Feb-12 3:56am    
Okay sorry you'd be surprised what we do see on this forum sometimes... Anyway, (assuming you remembered to escape special characters like dots (full stops) with a backslash in the first line) I don't know what your issue is...
rashidfarooq 6-Feb-12 8:52am    
thanks for reply. I have found the solution. I am gonna post the solution here.

1 solution

Fortunately, I have found the solution. I used the following code in .htaccess and now it is working fine.
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900