I have the following .htaccess file:
AddDefaultCharset utf-8
RewriteEngine on
Options +SymLinksIfOwnerMatch
RewriteBase /
# redirect all www-requests to no-www
# -
RewriteCond %{HTTP_HOST} ^www\.site\.com$ [NC]
RewriteRule ^(.*)$ http://site.com/$1 [R=301,L]
# redirect all home pages to / (root)
# -
RewriteCond %{THE_REQUEST} ^.*/index\.(php|html?)
RewriteRule ^(.*)index\.(php|html?)$ /$1 [R=301,L]
# remove trailing slash from dirs
# -
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/$ /$1 [R=301,L]
# automatically add index.php when needed
# -
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|login\.php|reg\.php|robots\.txt|css/|js/)
RewriteRule ^(.*)$ /index.php [L]
The .htaccess file should do the following (for SEO):
- Conversion to no-www (
http://www.site.com
should becomehttp://site.com
) - All URIs with trailing slashes should convert to no-trailing-slash:
http://site.com/me/
should be redirectedhttp://site.com/me
- All URIs with
index.php/index.html
should convert to just nothing:http://site.com/admin/index.php
orhttp://site.com/admin/
should be eventually displayed ashttp://site.com
However the current version of .htaccess results in a cyclic redirection when trying to access (http://site.com/admin
). The real document that should be fetched by browser is http://site.com/admin/index.php
.
Can anyone please help me with this issue?