Forum Moderators: phranque

Message Too Old, No Replies

Always redirect certain url paths to index.php

         

neophyte

11:12 am on Jul 7, 2010 (gmt 0)

10+ Year Member



Hello All -

In a previous project I kept all back-end files/functionality within a separate directory inside the root directory. So, if someone typed www.sitename.com/private/ they would be served the index.php file within the private directory. No problem.

Now I'm experimenting with the possibility of getting rid of the "private" directory - and all sub directories with it - so that when someone enters www.sitename.com/private/ only the index.php file within the ROOT directory will be called - index.php in the ROOT directory will now handle all "private" requests.

Anyway, I've tried the following in my .htaccess file (on my local dev environment):

Redirect /private/ index.php

but I keep getting server error 500 messages.

Anyone have an idea on how I can get this to work?

g1smd

3:15 pm on Jul 7, 2010 (gmt 0)

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



Do want the user to continue to see the exact same URL they requested, or do you want their browser to be told to make a new request for the root URL?

The answer decides whether to use a Rewrite or a Redirect, however both are going to be coded using a RewriteRule with appropriate flags.

neophyte

1:50 am on Jul 8, 2010 (gmt 0)

10+ Year Member



Hello g1smd -

Yes, ideally the url that the user requests will stay the same (e.g. www.sitename.com/private/) however, instead of the request triggering index.php WITHIN the /private/ directory (which no longer exists) the request will simply trigger the index.php file inside the site root.

Appreciate your question and looking forward to your answer!

Neophyte