Forum Moderators: phranque
# BLANK FILE EXTENSION TO .PHP
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ $1\.php
# CONVERT URI TO QUERYSTRING
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) module.php?query=$1 [L]
RewriteCond %{REQUEST_URI} !/$Never put something in a RewriteCond that can go in the body of the rule. Ordinarily this applies to positive REQUEST_URI matches-- but here you can avoid the condition by changing the rule itself from * to +
RewriteRule ^(.*)$ $1\.php
RewriteRule (.+) /$1\.php [L]
or RewriteRule ^([^.]+)$ /$1\.php [L]
(Uh-oh, did you really forget the [L] flag or was it just lost in posting?) Note that if you're saying [^blahblah] with a negative, the ^ and $ anchors are essential; if you're searching for any and all characters with .* or .+ you don't need anchors. Note also that targets should always start with / for security.
Options -MultiViews
# Custom Error Documents
ErrorDocument 404 /404.php
ErrorDocument 403 "<H1>Access denied</H1>"
RewriteEngine On
# RULE 1 - REQUIRE SSL RULE
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]
# RULE 2 - ALLOW BLANK EXTENSION MATCHING .PHP FILE
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ /$1.php?rewrite=true [L,QSA]
# RULE 3 - REQUEST URI TO QUERYSTRING
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)/?$ /index.php?modname=$1 [L,QSA]
RewriteEngine Oninside the following code:
<IfModule mod_rewrite.c>
</IfModule>
is the ErrorDocument code in the correct place?
inside the following code:
# RULE 1 - REQUIRE SSL RULE
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^(example\.com)?$
RewriteRule (.*) https://example.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(realdir|otherrealdir|thirdrealdir)/?$
It is worth going to some effort to save the server from having to look up whether a file exists, because this is about the most labor-intensive thing a server is ever asked to do. (Short of, ahem, the final step of really serving up the files!) RewriteRule ^([^.]+)/?$
^([^.]+[^./])/?$
Use the same pattern in any rule that calls for a no-final-slash capture. technically a filename can be there without extension (dot) so then keeping it there might be a better option wouldn't it?