Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite default url

mod rewrite default url

         

tinkerbot

3:54 pm on Mar 20, 2005 (gmt 0)

10+ Year Member



hello,

sorry if this has been answered before but i couldn't find it on the forum,

I am trying to redirect
[somewhere.com...] to [somewhere.com...]

RewriteEngine on
RewriteRule ^/$ /index.php?cat=1 [R]

didn;t work and neither did

RedirectMatch ^/$ [somewhere.com...]

any suggestions

Cheers

jdMorgan

5:38 pm on Mar 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



tinkerbot,

Welcome to WebmasterWorld!

> RedirectMatch ^/$ http://www.example.com/index.php?cat=1

You didn't say where you were putting your code, but the directive above should have worked in either httpd.conf or in .htaccess. If it's not working, investigate your settings for AllowOverride and Options. These need to be set up to give you "permission" to do redirects.

If you don't have access to the server config, then contact your hosting service and ask them why the above directive does not work.

I don't want to distract from the subject of this thread until you get the main problem resolved. But I cannot recommend doing an external redirect from "/" to /index.php?anything. You will have better search engine ranking results and a faster-responding and more professional-looking site if you do an internal rewrite instead. In this way, requests for "/" cause the server to serve index.php?cat=1, but the visitor's address bar never changes -- It still shows "yourdomain.com/". The visitor also does not have to wait while his browser re-fetches the content from the new URL. Once you get the main problem resolved, look into using an internal rewrite, or defining your index.php as the default index file to avoid doing any redirecting or rewriting at all (See Apache DirectoryIndex directive).

Jim

tinkerbot

11:08 am on Mar 21, 2005 (gmt 0)

10+ Year Member



Cheers for the help..... i decided to rewrite a bit of the index.php i was using to check to see if any args are passed and redirect them to the right page that way..... saves using mod_rewrite

Thanks anywayz