Some of Important .htaccess Codes Everyone Should Known

3,267 views

Published on

Some of Important .htaccess Codes Everyone Should Known

Published in: Technology, Design
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,267
On SlideShare
0
From Embeds
0
Number of Embeds
1,585
Actions
Shares
0
Downloads
5
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Some of Important .htaccess Codes Everyone Should Known

  1. 1. Some Of Important .htaccess Codes    
  2. 2. Redirect Non WWW to WWW RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule ^(.*) http://www.example.com/$1 [R=301]    
  3. 3. Redirect index.php to non index.php RewriteCond %{THE_REQUEST} ^.*/index.php RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]    
  4. 4. To Redirect WWW to Non WWW RewriteEngine On RewriteCond %{HTTP_HOST} ^www.example.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]    
  5. 5. For redirect all index.php url to non index.php in  magento (Ecommerce Websites) RewriteEngine on RewriteBase / RewriteCond %{THE_REQUEST} ^.*/index.php RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L] RewriteRule ^index.php/(.*) $1 [R=301,QSA,L]    
  6. 6. Changed your Pages from .html to .php RedirectMatch 301 (.*).html$ http://www.example.com$1.php    
  7. 7. To Redirect One page to Another Page Redirect /old-index.html http://www.mynewwebsite.com/foldername/new-index.html    
  8. 8. PHP Header Redirect <?php header ('HTTP/1.1 301 Moved Permanently'); header( "http://www.new-website.com" ); ?>    
  9. 9. To Redirect One Page to Another Page Redirect /old-index.html http://www.mynewwebsite.com/foldername/new-index.html    
  10. 10. To Start Inner Pages of WordPress Website # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress    

×