htaccess redirect all pages to index page


/ Published in: PHP
Save to your folder(s)

Redirects all requests to the index page, unless the file is an asset (css, javascript, image, etc). All directories (real or fake) get redirected to the index page. Note the file extensions (js|css|gif|jpg|jpeg|png|ico|swf|pdf) can be added and subtracted too, depending on your needs.


Copy this code and paste it in your HTML
  1. RewriteEngine on
  2. RewriteCond %{REQUEST_FILENAME} !\.(js|css|gif|jpg|jpeg|png|ico|swf|pdf)$
  3. RewriteCond %{REQUEST_URI} !=/
  4. RewriteRule ^(.*)$ / [L,R=301]

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.