Forum Moderators: phranque

Message Too Old, No Replies

htaccess and rewrite rule.

for this specific case...

         

brakkar

10:51 am on Mar 21, 2006 (gmt 0)

10+ Year Member



Hi,
on my site, I have many url that looks like: [mysite.com...]

I would like to know if it is possible to put something in the htaccess file so index.php/engine/ will be invisible to my users.

Thanks
Brakkar

anticulture

12:41 pm on Mar 21, 2006 (gmt 0)

10+ Year Member



Hello,

try putting


Options -Indexes

in a .htaccess file in the engine/ directrory or add this

rewriteCond %{THE_REQUEST} ^engine/
rewriteRule .* - [R=404]

to a/the .htaccess file in the mysite.com/ directrory

.... i think

jdMorgan

8:49 pm on Mar 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I would like to know if it is possible to put something in the htaccess file so index.php/engine/ will be invisible to my users.

Yes and no. mod_rewrite won't do this by itself, but it's one-half of the solution.

First change all the links* on all of your pages to eliminate the index.php/engine part of the URL. These links will now no longer point to a 'real file' when a user clicks on one.

So then we use mod_rewrite to 'fix' these URLs when they are requested from your server:


RewriteCond /index.php/engine%{REQUEST_FILENAME} -f
RewriteRule ^(.+)$ /index.php/engine/$1 [L]

Note that you may need to add a slash after index.php in the first line -- I'm not sure without testing it myself.

Also, it would be far more efficient if you could 'tag' these URLs that need to be rewritten, rather than using the 'file exists' test as shown. For example, use on-page links like /rl/<something> so that the rewrite code can simply look for the "rl/" prefix on a URL to know if it needs to be rewritten or not.

* Obviously, you should only change a few in order to test this method before changing all the links.

Jim