Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

301 redirect of an html page

hello,
can I use the following 301 on top of a .html page to give it a good 301 redirect. Pleae note that the site contained some old html pages that are no longer there. I want to do a redirect and am on shared hosting.
I can do a js redir but that only give google a 200 error not a 301. is it poss to add the code below to a html page.

<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.mysite.com/index.asp"
%>

regards

k
0
thatelvis
Asked:
thatelvis
  • 3
  • 3
1 Solution
 
hieloCommented:
>>give google a 200 error
200 is NOT an error code. It means the server found the file and sent it successfully.

>>can I use the following 301 on top of a .html page
If the file is infact named ".html" page then no. What you posted is ASP script and needs to be executed dynamically. That means that you would need to rename that file FROM filename.html TO filename.asp

BUT your new problem is that now browsers/bookmarks will still point to "filename.html" which now does not exist and they will get a 404 error.

>>. I want to do a redirect and am on shared hosting.
Ask your hosting provider if they have some provision that will allow you to redirect (like mod_rewrite).
0
 
ahmad2121Commented:
You can do this in IIS very easily, or via the Web.config.

The web.config trick might only work with IIS7, you'll have to try it.

This will work at the folder level, but not so much the file level.
    <system.webServer>
        <httpRedirect enabled="true" destination="http://theworld.com/whatever$S$Q" exactDestination="true" httpResponseStatus="Permanent" />
    </system.webServer>

Open in new window

0
 
thatelvisAuthor Commented:
thank you, i am on a shared windows server at crystaltech. I dont know what to do with the above code (where would i stick it (don't be rude lol))

k
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ahmad2121Commented:
If thats the case then I don't know how you could be able to do it easily.

The web.config file resides in the root of your application. One application root can have many other nested applications in it, but they have to be physically configured through IIS. Which you don't have access to.

Which means, you can only do this at the root. Which means its useless unless you want to redirect all the root files to one particular location.

In your scenario, you can try the following: Create a folder with the exact file name and put all your aspx code in the default page inside that folder.

For example:

So if you have a file called mystuff.html and you want it to execute ASPX or go somewhere else via 302. Create a folder called "mystuff.html" (exact spelling), then create a Default.aspx or Index.aspx and put your redirection code inside that ASPX file.
0
 
thatelvisAuthor Commented:
Hello Ahmad

brilliant concept  "So if you have a file called mystuff.html and you want it to execute ASPX or go somewhere else via 302. Create a folder called "mystuff.html" (exact spelling), then create a Default.aspx or Index.aspx and put your redirection code inside that ASPX file."

how seo is it

regarsd

k
0
 
ahmad2121Commented:
That's a good question. It all depends on how you link to it and how smart the search engine is.

I don't think you need to worry because if

http://www.mysite.com/mystuff.html

is a folder, the request is accepted and they are transferred to

http://www.mysite.com/mystuff.html/

Which shouldn't disturb the request. As long as you don't start linking to the default page:

http://www.mysite.com/mystuff.html/Default.aspx
0
 
thatelvisAuthor Commented:
thank you very much. happy new year
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now