Please help me, how i can customize this code because not works like this ------------------------------------- <% If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www." & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("REQUEST_URI") Response.End End if %> ------------------------------ or please give me some tips for Canonical Hostname Redirect (non-www to www) IIS - asp
That is asp code so make sure you page has a .asp extension (not .html or .php or .aspx or anything else).
Try this (change to your file extension and domain name). RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.htm\ HTTP/ RewriteRule ^index\.htm$ http://[B]www.xxxxx.com/[/B] [R=301,L] RewriteBase / RewriteCond %{HTTP_HOST} ^xxxxx.com$ RewriteRule ^(.*)$ http://[B]www.xxxxx.com[/B]/$1 [R=301,L]
i tried like that; <% If InStr(Request.ServerVariables("xxxxxxxxxxx.com"),"www") = 0 Then Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www." & Request.ServerVariables("xxxxxxxxxxx.com") & Request.ServerVariables("asp") End if %> finanly not worked
500 error almost always puts the error into the webserver's error logs. The error even says that it's doing so. Did you check to see what the issue is?