10
 Some Of Important .htaccess Codes

Some of Important .htaccess Codes Everyone Should Known

  • Upload
    arcful

  • View
    3.348

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Some of Important .htaccess Codes Everyone Should Known

  

Some Of Important .htaccess Codes

Page 2: Some of Important .htaccess Codes Everyone Should Known

  

Redirect Non WWW to WWW

RewriteEngine onRewriteBase /RewriteCond %{HTTP_HOST} ^example\.com$RewriteRule ^(.*) http://www.example.com/$1 [R=301]

Page 3: Some of Important .htaccess Codes Everyone Should Known

  

Redirect index.php to non index.php

RewriteCond %{THE_REQUEST} ^.*/index.phpRewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]

Page 4: Some of Important .htaccess Codes Everyone Should Known

  

To Redirect WWW to Non WWW

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]

RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

Page 5: Some of Important .htaccess Codes Everyone Should Known

  

For redirect all index.php url to non index.php in magento (Ecommerce Websites)

RewriteEngine onRewriteBase /RewriteCond %{THE_REQUEST} ^.*/index.phpRewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]RewriteRule ^index.php/(.*) $1 [R=301,QSA,L]

Page 6: Some of Important .htaccess Codes Everyone Should Known

  

Changed your Pages from .html to .php

RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php

Page 7: Some of Important .htaccess Codes Everyone Should Known

  

To Redirect One page to Another Page

Redirect /old-index.html http://www.mynewwebsite.com/foldername/new-index.html

Page 8: Some of Important .htaccess Codes Everyone Should Known

  

PHP Header Redirect

<?php header ('HTTP/1.1 301 Moved Permanently'); header( "http://www.new-website.com" ); ?>

Page 9: Some of Important .htaccess Codes Everyone Should Known

  

To Redirect One Page to Another Page

Redirect /old-index.html http://www.mynewwebsite.com/foldername/new-index.html

Page 10: Some of Important .htaccess Codes Everyone Should Known

  

To Start Inner Pages of WordPress Website

# BEGIN WordPress

<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule>

# END WordPress