Forum Moderators: phranque
# Dont list files or folders
Options -Indexes
#
# Dont show server details
ServerSignature Off
#
RewriteEngine On
RewriteBase /
#
# Add WWW
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) http://www\.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#
# add trailing slash if missing
rewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ $1/ [R=301,L]
#
# Allow Access to real files or folders
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#
# Everything else goes to loader
RewriteRule ^(.*)$ loader.php?t=$1 [L,QSA]
#
# CACHE EVERYTHING...
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# Html
ExpiresByType text/html "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
# Music
ExpiresByType audio/mp3 "access plus 1 year"
</IfModule> Options -Indexes
ServerSignature Off
RewriteEngine On
# Combined these...
RewriteRule ^(files|loader\.php) - [L]
RewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ http://www.example-example.com/$1/ [R=301,L]
# Removed to stop redirect to directory only view
#RewriteCond %{REQUEST_URI} ^/((?:\w+/)*)index\.\w
#RewriteRule index\.(?:php|html)$ http://www.example-example.com/%1 [R=301,NS,L]
RewriteCond %{HTTP_HOST} !^(www\.example-example\.com)?$ [NC]
RewriteRule (.*) http://www.example-example.com/$1 [R=301,L]
# Added this rewrite rule to catch genuine files - it's the only way I could make the change below work - from ^([^.]*)$ to ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^([^.]*)$ /loader.php?t=$1 [L,QSA]
# Changed above rule - into the below to catch everything...
RewriteRule ^(.*)$ /loader.php?t=$1 [L,QSA] any request to a "index.php" file is now redirected to just the directory. (e.g /directory/index.php becomes /directory/)No, you don't. What is happening now is what should be happening. For any given page, there should be only one URL to reach it. That's why every site has an index redirect. (Here "page" means "page that is seen by the visitor", whether or not it physically exists on the server.)
I really need:
example.com/directory/
and
example.com/directory/index.php
to both be QSA loaded by the loader.php - which handles the page.
I wanted users to be able to access bothFor a human user, a redirect is transparent. So even if they've got the "wrong" form bookmarked, they'll get to the right URL and never even notice the difference.