Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule for root directory

         

Psychopsia

2:04 am on Sep 13, 2006 (gmt 0)

10+ Year Member



Hi all!

I need some advice on a rewrite rule:

Actually I have "index.php" that redirects to http://www.example.net/cover/ , "cover" is an internal rewrite:

RewriteRule ^cover/$ somedir/index.php [nc]

But I want to remove the cover rewrite, and when people enter to site http://www.example.net (without the "/cover/") rewrite internally to /somedir/index.php
I test the following rule and it works but don't know if this will bring up another problems:

RewriteRule ^$ somedir/index.php [nc]

Can you help me please?

Thanks in advance!

matc

1:24 am on Sep 14, 2006 (gmt 0)

10+ Year Member



Hi,

This seems more a server load issue than anything else. It seems that every time someone comes to the front door of your site they fire the under the hood redirect. Could UNIX be handy here and the option of setting up a symbolic link instead? [scism.sbu.ac.uk...]

cheers, mat

Psychopsia

1:55 pm on Sep 14, 2006 (gmt 0)

10+ Year Member



I think it's better using a Rewrite, or Im wrong?

jdMorgan

8:30 pm on Sep 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Either way should work, and they're essentially equivalent.

I don't see anything problematic about what you're doing. Do you have some specific concern in mind?

Jim

Psychopsia

11:56 pm on Sep 14, 2006 (gmt 0)

10+ Year Member



Thanks for your reply Jim.
Just another question:

I don't have to upload an index.php (in root directory) in this case, right? because apache rewrites instantly after enter the site, without calling a file in the DirectoryIndex list.

Or I should keep an index file for some reason?

jdMorgan

3:46 am on Sep 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There will be no requirement to have an index file there, since it will be inaccessible when the rewrite is active. You might want to put a file there, though, that says something like "A serious server configuration error exists that is preventing this site from working. Please report this to the Webmaster immediately." And provide a simple e-mail link to contact you.

This config error file will never be served unless you accidentally delete your .htaccess file, delete the rewriterule in that file, or make a coding error that prevents mod_rewrite from running, or if your FTP upload of a modified .htaccess fails due to a network problem. If any of those things happen, having this "error file" might save you from the site being down all day if you forget to check it after each upload.

I do check my site after each upload, but I also have a similar error file in place in case I forget and something goes wrong. I call it being thorough - Fix or handle possible problems ahead of time if you can.

Jim

Psychopsia

4:03 pm on Sep 15, 2006 (gmt 0)

10+ Year Member



Thank you Jim! for all your explanation.