Forum Moderators: phranque

Message Too Old, No Replies

.htaccess being really strange and illogical

         

daktau

4:05 pm on Feb 16, 2010 (gmt 0)

10+ Year Member



Hi,
Firstly here is my .htaccess fgile in it's entiretly


RewriteEngine on
Options +FollowSymlinks


RewriteRule ^home$ index.php
RewriteRule ^aboutus$ aboutUs.php
RewriteRule ^contact$ contact.php
RewriteRule ^weddingcakes$ weddingCake_1.php
RewriteRule ^birthdaycakes$ birthdayCakes.php
RewriteRule ^individualcakes$ individualCakes.php
RewriteRule ^chocolateshoes$ chocolateShoes.php

#all 404's go to index
ErrorDocument 404 /index.php


- contact is the only page that works properly. It has a link that is www.website.com/contact and delivers the right page whilst maintaining the link in the browser
- All others act differently. e.g. They go from www.website.com/chocolateshoes to www.website.com/chocolateshoes.php/
- Weirdly www.website.com/aboutus forwards on to www.website.comaboutUs.php resulting in a server not found message.

Why are not all the links behaving as the contact one?

thanks a lot,
George

jdMorgan

5:09 pm on Feb 16, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try disabling MultiViews/content-negotiation by changing your options to:

Options +FollowSymLinks -MultiViews

Try adding a leading slash to the replacement paths, and add an [L] flag to each rule, thusly:

RewriteRule ^aboutus$ [b]/a[/b]boutUs.php [b][L][/b]

Completely-flush your browser cache before testing any modified code.

If this does not help, dig into all .htaccess files and server config files, and make sure that there is no external redirect directive that could run after these internal rewrites are invoked. There's no reason that you should be able to "see" that malformed "www.website.comaboutUs.php" URL in your browser unless an external redirect is being invoked after the rewrite -- a code design problem which is incorrect on principle. mod_negotiation, mod_dir, mod_alias, and mod_rewrite can all do redirects, and the trick is to find out which one is (or ones are) responsible, then re-arrange the code so that all external redirects occur before any internal rewrites can be invoked. I started with mod_negotiation above, because it's the most frequent culprit, often enabled by your host whether you ever need it or not, and able to de-rail the best of rewriterules.

It is an SEO error to use your home page as a 404 error document. Put up a proper custom 404 error page that clearly and somewhat-apologetically explains the problem to your visitors, and provide helpful navigation links: Home page, site search, major category indexes, etc. as applicable. Solicit user reports of any bad links within your own site.

If you can't do that, then don't use the ErrorDocument directive; just let the server serve it's default 404 error message.

Jim

daktau

5:18 pm on Feb 16, 2010 (gmt 0)

10+ Year Member



Thanks a lot. Just when you think that you've something sussed.......I will try and get to the bottom of this.

cheers,
George