Bill Henderson
asked on
PHP to ASP translation
Hi,
I have a redirect script that I need to insert on certain site pages. I've done this with PHP, but I'm not sure what the equivalent code would be for ASP. The gist is to sense if www. is missing from the URL and insert it with a new header. Here is the PHP:
if(strstr($_SERVER['HTTP_H OST'],'www .')==false ) header("LOCATION:https://www.website.com");
Can anyone tell me what would be the equivalent ASP line of code to accomplish this?
(Yes I know URL rewrite is a better option - in this case, however, I need to accomplish this only when the one particular ASP file loads.
Any suggestions?
Thank you
Bill
I have a redirect script that I need to insert on certain site pages. I've done this with PHP, but I'm not sure what the equivalent code would be for ASP. The gist is to sense if www. is missing from the URL and insert it with a new header. Here is the PHP:
if(strstr($_SERVER['HTTP_H
Can anyone tell me what would be the equivalent ASP line of code to accomplish this?
(Yes I know URL rewrite is a better option - in this case, however, I need to accomplish this only when the one particular ASP file loads.
Any suggestions?
Thank you
Bill
This is a good reference http://www.webconfs.com/how-to-redirect-a-webpage.php
ASKER
I think I should have mentioned - I want them to be redirected to the same page. In other words - I'm just trying to insert www. and take them right back to this page. Won't it go into some kind of loop?
We want to redirect ONLY if they don't have www. in the URL to www. of the same asp file.
Does this make sense?
Bill
We want to redirect ONLY if they don't have www. in the URL to www. of the same asp file.
Does this make sense?
Bill
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks for the help!
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.new-url.com/"
%>
or a simple
response.redirect("mypage.