Dynadot โ€” .com Transfer

ASP 301 redirect from www to non

Spaceship Spaceship
Watch

tgo

Established Member
Impact
7
I am looking to create a 301 redirect from my www(dot)name.com to just name.com

I run a dedicated windows server so I cant use htaccess, I also dont pay for mod rewrite. So how can I redirect the www to non www.

I can write asp that does the 301, but how do I detect that there is a www in the url? Do I just read the current page name and do a instring function to check? Then redirect to itself without the www if needed....

Any easier way to do this? This way I would have to have this code on all my pages to jump out of www when needed.
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
i would think redirecting to a link without the www will work
 
0
•••
Sorry I don't know ASP, but here's the code in PHP, I hope it helps!

PHP:
if ($_SERVER['HTTP_HOST'] == "http://www.mysite.com")
{
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://mysite.com");
}
 
0
•••
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back