Hi, I have tried upload .htaccess for URL redirection for my website. But it looks the code is not working. I have hosted my site in Windows server. Kindly help me how to clear that error. Below is code i used in the .htaccess file what I have uploaded. RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.htm\ HTTP/ RewriteRule index\.htm$ http://www.mysite.com/%1 [R=301,L] ErrorDocument 404 /AnErrorPage.html
First thing to check is whether the server is running Apache or IIS? A lot of Windows servers run IIS as it integrates easily in which case .htaccess won't do anything. I'd comment out the second RewriteCond and RewriteRule with # and see if it then at least redirects from the non www. to the www. version. Easiest to break the thing down and then see what works. The first 2 rules look like they should work. The other two are a bit complicated to read currently, but if the above works then we could look closer at them. Trev
As you said my site is hosted in Server: Microsoft-IIS/6.0 , But could you please give me a clear idea on how to edit the rule using # Nick
IIS mod-rewrite modules exist for IIS but it doesn't come with the ability to rewrite urls on its own. You will need either a third party plugin or do it the cool dude way, setup IIS to have ASP.NET's engine handle the web-requests and control it all manually - look into the MVC, which I believe comes with that power.