Forum Moderators: phranque

Message Too Old, No Replies

.htaccess rule / index.php / 301 back-end problem

.htaccess joomla index.php

         

modro

10:12 pm on Mar 7, 2009 (gmt 0)

10+ Year Member



Hi,
In order to standardized on a single use of either the / or /index.{ext} for my Joomla installation I added to my .htaccess:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php /$1 [R=301,L]

It works fine in the front-end but causes problems in the back-end (admin area):

[domian.com...]

is being redirected to [domian.com...]

how can I modify the rule to avoid the administrator directory from being affected?

g1smd

11:48 pm on Mar 7, 2009 (gmt 0)

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



That version of the redirect uses .* and hence is very very inefficient. Check forum posts for a more specific pattern that avoids the problem.

For your question, add a negative match RewriteCond that examines the client request to see if it contains a reference to the 'administrator' folder.

modro

12:07 am on Mar 8, 2009 (gmt 0)

10+ Year Member



Thanks for you fast response!

adding

rewritecond %{REQUEST_URI} !^/administrator/

solved the problem.

---> I will look for a better solution for the ".*" - if somebody has a brilliant idea, please feel free to post.

jdMorgan

9:28 pm on Mar 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



^(.*).index\.php$ <-- ^(([^/]+/)*)index\.php$

For efficiency, you may omit the outer parentheses for use in the RewriteCond pattern only.

Jim