Forum Moderators: phranque

Message Too Old, No Replies

redirecting non file endings to proper files

         

surrealillusions

3:11 pm on Aug 6, 2010 (gmt 0)

10+ Year Member



Hi all,

Is there a simple rewrite rule for .htaccess to redirect all directory url's to the relevant file.

For example:

Theres a page called competition.php and I would like competition/ to redirect to that file. Plus for all other pages. I could create each directory and put a redirect file in there, or create a line for each page in the .htaccess, but is there a catch all code?

Thanks.

jdMorgan

4:08 pm on Aug 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Simple, no. But this thread [webmasterworld.com] may be of use to you. Note that the thread was named by the original poster, and reflects his thoughts, not ours... :)

I strongly suggest that you *do not* use URLs with trailing slashes for *pages*. Trailing slashes should be reserved for directories or for directory index pages. Avoid making each of your URLs one character longer (for no benefit), make them easier to type-in directly and to "announce" on the phone or radio or TV, and avoid problems with the way that browsers resolve page-relative links.

Jim

surrealillusions

10:51 pm on Aug 6, 2010 (gmt 0)

10+ Year Member



Hmmm...interesting :) That thread has alot of scary htaccess code rewrites...

The reason why I would of liked to do this is for the purpose of making the url look prettier, for links on various sites and that.

The site is relatively small, so I guess for those links that I am looking to promote, maybe a page or 3 here and there, it'd be easier just to make the directory and redirect the index file in there to the appropiate page.

Thanks.

:)

g1smd

1:45 am on Aug 7, 2010 (gmt 0)

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



You certainly don't want to be "redirecting" if you can help it.

Not only does it mess up your site stats, it also signals a site of 'low technical quality' to some search engines.