Let's just use hypothetical examples because I've found a number of pages explaining 301 redirects, but I'm doing something wrong, so I'll just have someone respond if possible with my example. So I want to redirect my old url: www.randomsite.com/chapstick/index.html to www.randomsite.com/lipstick.php Can someone show me the exact code to do this including my examples...I'm afraid i'm a bit daft for it to work any other way. Thanks so much!
Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^randomsite.com/chapstick/index.html [nc] rewriterule ^(.*)$ www.randomsite.com/lipstick.php$1 [r=301,nc] Code (markup): Add this into your htaccess in the root of the public_html. Also notice with the randomsite URL there is no http:// or www in front of it.
I created an htaccess file, put in the code making the changes and everything, but it's not working. Where do I upload it to on my server/what do you mean public_html? In the chapstick folder or the randomsite folder on my server?
Does it make a difference if I have windows or hosting or what not? I'm running Windows Vista, I use dreamweaver for html editing, use notepad to create a .htaccess file, and use godaddy hosting. Please someone help me with this!
It matters what godaddy is using. Apache? Which version? Gamernz, I didn't understand the $1 after the lipstick.php in the rewrite... is something supposed to come after lipstick.php?? I understand it's a capture but what is iti supposed to be capturing?
I'm not sure what it is, I emailed them for more assistance about this whole redirect thing as I've tried sooo many suggestions and methods but I must be doing something wrong every single time because every time I try going to the old page hoping for a redirect it's still there, same as always!
That's a good idea. Apache isn't the only server out there. A Windows server likely runs IIS (though you can also run Apache on it). There are also other servers out there like lighttpd and nginx. There are two major versions of Apache: 1.3 and 2.x, and I've heard that there's a difference between them whether you start your patter with ^/ or just ^. You can be safe and do ^/? (slash is an option) which works for either version. (if ServerSignature is on, your 404 page should state what server you're using and which version, so you can also go to a page you know doesn't exist and see if the signature after the error is there).
Godaddy mailed me back and said: The hosting account you are currently running is a Windows shared hosting account. With the Windows based hosting, you will want to use the ASP code for the redirect, as PHP runs off of the Linux hosting accounts. Below is the code they gave me in an earlier email: ASP Code - save this as oldpagename.asp <%@ Language=VBScript %> <% Response.Status="301 Moved Permanently" Response.AddHeader "Location", "http://www.new-url.com" %> SO USING MY EXAMPLE FROM EARLIER IT SHOULD LOOK LIKE: Saved as chapstick.asp <%@ Language=VBScript %> <% Response.Status="301 Moved Permanently" Response.AddHeader "Location", "http://www.randomsite.com/lipstick.php" %> Does this look correct? Where do I upload it to on my server considering it's for the same domain? The root folder of "randomsite"? THANKS FOR HELPING ME EVERYONE!
Well actually wouldn't you want to put it where the old url is? The point is, when people go to www.randomsite.com/chapstick/index.html you want those people to get the redirect, right? So that ASP code they gave you should have the same name as that file (index.html), in the chapstick folder like pneulameiro said. If the file is called "index.asp" and people go looking for "index.html" they shouldn't be getting the redirect as those would be two different files, wouldn't they?