Last Updated: February 25, 2016
· acrogenesis

.htaccess hacks

Specify the Directory Index:

DirectoryIndex newindex.html

Specify 404 error:

ErrorDocument 404 /404error.html

Redirect 301

Redirect 301 /old.html /new.html

Resolve www (make become

RewriteEngine On RewriteCond %{HTTP_HOST} ^ [nocase] RewriteRule ^(.*)$1 [last,redirect=301

Deny access to specific ip (

order allow,deny deny from allow from all

Prevent Hot linking

RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?*$ [NC] RewriteRule \.(gif|jpg|css)$ - [F]

Make redirect to (SEO Remove duplicate index page)

RewriteEngine on # For index.html and index.htm only, without parameters, and only in the root: RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html?\ HTTP/ RewriteRule ^index\.html?$$1 [R=301,L]

Redirect a folder can be same site or a diferent site

RewriteRule ^sma/delicias(.*)$$1 [L,R=301]

2 Responses
Add your response

Can I make the redirection from index.html to work with an index.php?

over 1 year ago ·

Use this

Options +FollowSymLinks
DirectoryIndex index.php

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php HTTP/
RewriteRule ^index.php$ [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
over 1 year ago ·