Skip to content

Instantly share code, notes, and snippets.

@avtobys
Last active October 24, 2022 19:41
Show Gist options
  • Save avtobys/5d7ca03e393977e534cccced8863e9be to your computer and use it in GitHub Desktop.
Save avtobys/5d7ca03e393977e534cccced8863e9be to your computer and use it in GitHub Desktop.
.htaccess with slashes
DirectoryIndex index.php
AddDefaultCharset UTF-8
Options -Indexes
<ifModule mod_headers.c>
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteCond %{THE_REQUEST} //
RewriteRule .* %{REQUEST_SCHEME}://%{SERVER_NAME}/$0 [R=301,L]
RewriteCond %{REQUEST_URI} ^(.+)/index\.(php|html)
RewriteRule ^(.+/)index\.(php|html)([^/]*)$ %{REQUEST_SCHEME}://%{SERVER_NAME}/$1 [R=301,L]
RewriteCond %{THE_REQUEST} /index\.(php|html)
RewriteRule ^index\.(php|html)([^/]*)$ %{REQUEST_SCHEME}://%{SERVER_NAME}/ [R=301,L]
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !(\.html|\.txt|\.xml)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ %{REQUEST_SCHEME}://%{SERVER_NAME}/$1/ [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment