Skip to content

Instantly share code, notes, and snippets.

@areski
Created September 14, 2014 18:00
Show Gist options
  • Save areski/4bf63d75d6b110aa4272 to your computer and use it in GitHub Desktop.
Save areski/4bf63d75d6b110aa4272 to your computer and use it in GitHub Desktop.
Wordpress HTAccess
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A300
ExpiresByType application/x-javascript A3600
ExpiresByType text/css A3600
ExpiresByType image/gif A3600
ExpiresByType image/png A3600
ExpiresByType image/jpeg A3600
ExpiresByType text/plain A300
ExpiresByType application/x-shockwave-flash A3600
ExpiresByType video/x-flv A3600
ExpiresByType application/pdf A3600
ExpiresByType text/html A300
</IfModule>
#
# Apache/PHP/Drupal settings:
#
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.DOMAINNAME\.DOMAINEXT$ [NC]
RewriteRule ^(.*)$ http://www.DOMAINNAME.DOMAINEXT/$1 [R=301,L]
RewriteRule ^home(.*)$ http://www.DOMAINNAME.DOMAINEXT/ [R=301,L]
# If you want to remove the www, comment the above and uncomment the next 3 lines
#RewriteEngine On
#RewriteCond %{HTTP_HOST} ^www.DOMAINNAME.DOMAINEXT$ [NC]
#RewriteRule ^(.*)$ http://DOMAINNAME.DOMAINEXT/$1 [R=301,L]
# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
Order allow,deny
</FilesMatch>
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Follow symbolic links in this directory.
Options +FollowSymLinks
# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php
# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /home
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment