Forum Moderators: phranque

Message Too Old, No Replies

301 redirect does not work

         

surrealillusions

5:04 pm on Nov 14, 2008 (gmt 0)

10+ Year Member



Hi all,

Just wondering if theres any specific reason why a 301 redirect wont work?

redirect 301 /contact.html [test.example.co.uk...]

thats the only line in my htaccess file, ive uploaded it via ascii and not binary via ftp. The site is definatly on apache..but, when i type in the address for contact.html into the browser, it gives a 404 error, shouldnt it go to the contact.php instead? Is it because its on a subdomain?

thanks

:)

g1smd

6:36 pm on Nov 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What folder did you upload it to?

Maybe redirects aren't allowed by your host?

.

In any case, if you simply want to use a .html URL but your file has a PHP script in it, then you can use AddType or AddHandler to set things so that URLs ending in .html are also parsed for PHP content.

No need for any redirects or rewrites in that situation.

[edited by: g1smd at 6:38 pm (utc) on Nov. 14, 2008]

jdMorgan

6:37 pm on Nov 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What happens if you type in http://test.example.co.uk/contact.php directly? If that doesn't work, then there's no way it'll work through a redirect. An error would liekly indicate a problem with your DNS setup or with the server "mapping" of the new subdomain to your existing account's filespace.

Did you completely flush your browser cache before testing this new code? If not, then your browser will likely show you a cached copy of the (non-existent) page and its associated 404 response, and no request will be sent to your server. So in this case, there is also no way the redirect will work.

Lastly, your host may not have set the Apache AllowOverride and Options directives to allow you to use .htaccess and mod_alias. If not, you can either beg and plead with them, or change hosts.

Jim

surrealillusions

7:53 pm on Nov 14, 2008 (gmt 0)

10+ Year Member



"you can use AddType or AddHandler to set things so that URLs ending in .html are also parsed for PHP content."

Tried that but that didnt work either.

the contact.php works, thats an actual file.

Tried it with a browser that i havent accessed the site with and that returned a 404.

Maybe htaccess is not allowed...will contact my host and see what they say

:)

jdMorgan

8:43 pm on Nov 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The other possibility is that you've got the code in the wrong place. It will have to be in the .htaccess file located in the filespace of the domain where you are requesting /contact.html from, which I suppose is either in your main domain folder or in your test subdomain's folder -- You didn't say, so I'm guessing.

Jim

surrealillusions

10:45 pm on Nov 14, 2008 (gmt 0)

10+ Year Member



oh yeah...all the files are in the same folder, which is the root folder of the test subdomain.

ive contacted the host about it, see what they say, see if some htaccess features are blocked.

:)