Forum Moderators: phranque

Message Too Old, No Replies

Hide index.php for main page only

         

AITBeginner

4:18 am on Jan 17, 2011 (gmt 0)

10+ Year Member



Hi all,

I need your advise and expertise.

I set a rewrite rules to hide index.php, the rule as follow:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.php[?]? [NC]
RewriteRule ^(([^/]+/)*)index\.php$ [domain.com...] [NC,R=301,L]

It will hide the index.php and it works fine.

If i open www.domain.com/index.php it will be resolved to www.domain.com.

However, i have another subfolder with index.php also which is affected by the rule also.

If i open www.domain.com/administrator/index.php, it will be resolved to www.domain.com/administrator/

The result, i could not login to the administrator webpage because the index.php is hidden.

How to fix the rewrite rule to only applies on the main www.domain.com only ?

Regards,


Kelvin

g1smd

8:33 am on Jan 17, 2011 (gmt 0)

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



Remove the ([^/]+/)* part of the pattern as it is this which finds and captures the folder names to any depth.

However, the admin function should not have been affected by your original change.

AITBeginner

10:52 pm on Jan 17, 2011 (gmt 0)

10+ Year Member



Hi g1smd,

Thanks sooo much for your help.
It works well!

Much appreciated.

Kevin

g1smd

11:55 pm on Jan 17, 2011 (gmt 0)

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



You should also investigate why the admin function failed.

It is likely that adding a "DirectoryIndex index.php" directive to the .htaccess file in the appropriate folder will fix that problem.