Note that there are some explanatory texts on larger screens.

plurals
  1. PO.htaccess mod_rewrite exemptions
    text
    copied!<p>Using a template I have this .htaccess mod_rewrite code that makes my URL's pretty:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteRule ^posts.php$ posts.php [L] # Rewrite www to no-www domain RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule .* http://%1%{REQUEST_URI} [R=301,L] # Rewrite multiple slashes with single slash after domain RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.*)\sHTTP/[0-9.]+$ [OR] RewriteCond %{THE_REQUEST} ^[A-Z]+\s(.*/)/+\sHTTP/[0-9.]+$ RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L,NE] # Rewrite multiple slashes with single slash in URL RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ RewriteRule . %1/%2 [R=301,NE,L] # Remove slash from URL end RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} ^(.+)/$ RewriteRule ^.+/$ %1 [R=301,NE,L] # Rewrite backslash with slash ## Works on FF with using AllowEncodedSlashes On in content/httpd.conf RewriteCond %{REQUEST_URI} ^(.*)\\(.*)$ RewriteRule .* %1/%2 [R=301,NC,L] # Rewrite query string, Ajax crawling RewriteCond %{QUERY_STRING} ^_escaped_fragment_=(.*)$ RewriteRule .*$ %{REQUEST_URI}%1? [R=301,L] RewriteCond %{QUERY_STRING} ^.+$ RewriteCond %{QUERY_STRING} !^url= RewriteCond %{QUERY_STRING} !api RewriteRule .*$ %{REQUEST_URI}? [R=301,L] # Rewrite space with dash RewriteCond %{REQUEST_URI} ^([^\ ]*)\ (.*)$ RewriteRule .* %1-%2 [R=301,L] # Rewrite underscore with dash RewriteCond %{REQUEST_URI} ^([^\_]*)\_(.*)$ RewriteRule .* %1-%2 [R=301,L] # Remove dot RewriteCond %{REQUEST_URI} ^([^\.]*)\.(.*)$ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* %1%2 [R=301,L] # Remove comma RewriteCond %{REQUEST_URI} ^([^\,]*)\,(.*)$ RewriteRule .* %1%2 [R=301,L] # Remove dash before slash RewriteCond %{REQUEST_URI} ^(.*)\-/(.*)$ RewriteRule ^(.*)\-/(.*)$ %1/%2 [R=301,L] # Remove dash after slash RewriteCond %{REQUEST_URI} ^(^\.)\/-(.*)$ RewriteRule ^(.*)\/-(.*)$ %1/%2 [R=301,L] # Remove .php extension RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*[^.]+\.php(\?[^\ ]*)?\ HTTP/ [NC] RewriteRule ^(([^/]+/)*[^.]+)\.php$ http://%{HTTP_HOST}/%1$1 [R=301,L] # Rewrite uppercase letter URL to lowercase with content/httpd.conf RewriteMap lc int:tolower ## Solution without httpd.conf RewriteMap in github.com/laukstein/ajax-seo/wiki/Lowercase-URL RewriteCond %{REQUEST_URI} .+ RewriteRule ^[^A-Z]*[A-Z] ${lc:%0} [R=301,L] # Block folder access that begins with a period (like .git, .svn) RewriteRule "(^|/)\." - [F] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^api/?([^\./]*)$ ?api&amp;url=$1 [L,QSA] RewriteRule ^([^.]*)$ ?url=$1 [L,QSA] RewriteRule .* - [E=HTTP_IF_MODIFIED_SINCE:%{HTTP:If-Modified-Since}] RewriteRule .* - [E=HTTP_IF_NONE_MATCH:%{HTTP:If-None-Match}] </code></pre> <p></p> <p>I've managed to create an exemption to allow the posts.php file to be accessed - However I am clueless on how to allow my pages to access all images stored in the /uploads/ path.</p> <p>Many thanks, Mike</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload