In general, we should never use .htaccess files unless we don't have access to the main server configuration file.
.htaccess files should be used in a case where the content providers need to make configuration changes to the server
Here are few rewrite rule has been listed which have to kept in .htaccess file, to get effect
Note:Sometime for use of .htaccess file css and image are not comming.So to prevent that we have to use rewrite rule in the htaccess file that rewrite rule also listed here.
REDIRECT NON WWW URL TO WWW URL
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
If Any Error occure then redirect it to a specified pageRewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
ErrorDocument 400 /root_path/page name(error.php?error_id=400)
ErrorDocument 401 /root_path/page name(error.php?error_id=401)
ErrorDocument 403 /root_path/page name(error.php?error_id=403)
ErrorDocument 404 /root_path/page name(error.php?error_id=404
ErrorDocument 405 /root_path/page name(error.php?error_id=405
ErrorDocument 408 /root_path/page name(error.php?error_id=408
ErrorDocument 415 /root_path/page name(error.php?error_id=415
ErrorDocument 500 /root_path/page name(error.php?error_id=500
ErrorDocument 501 /root_path/page name(error.php?error_id=501
ErrorDocument 502 /root_path/page name(error.php?error_id=502
ErrorDocument 503 /root_path/page name(error.php?error_id=503
ErrorDocument 505 /root_path/page name(error.php?error_id=505
ErrorDocument 504 /root_path/page name(error.php?error_id=504
HomePage Redirection
RewriteRule ^(demo\.php)?$ root_path/index.php [L]
HTMLPage Redirection
RewriteRule prefix_name_([0-9]+)_([0-9]+)_([0-9]+).html$ root_path
/pagename?ist_arg=$1&2nd_arg=$2&3rd_argD=$3 [L]
RewriteRule prefix_name_([0-9]+)_([0-9]+)/([^/]*).html$
root_path/pagename?ist_arg=$1&2nd_arg=$2&3rd_argD=$3 [L]
RewriteRule prefix_name_([0-9]+)/([^/]*).html$
root_path/pagename?ist_arg=$1 [L]
Extension Change Redirection
RewriteRule page.html$ root_path/pagename.php?arch=1 [L]
RewriteRule prefix_name_([^/]*)_([0-9]+).html$ root_path/pagename.php?2nd_arg=$2 [L]
RewriteRule prefix_name_([^/]*).html$ root_path/pagename.php?ist_arg=$1 [L]
Rewrite a profile page with htaccess
RewriteRule wordphase/([^/]*)$ pagename.php?qs=$1
If css is not comming rewrite page with htaccess
RewriteRule ^.*/css/style.css$ css/style.css
If image is not comming rewrite page with htaccess
RewriteRule ^.*/images/([^/]*)\.(jpggifpngsvg)$ images/$1.$2
How to rewrite Capital Letter file name to small file name
rewriterule ([^A]*)A(.*) $1a$2
rewriterule ([^B]*)B(.*) $1b$2
rewriterule ([^C]*)C(.*) $1c$2
rewriterule ([^D]*)D(.*) $1d$2
rewriterule ([^E]*)E(.*) $1e$2
rewriterule ([^F]*)F(.*) $1f$2
rewriterule ([^G]*)G(.*) $1g$2
rewriterule ([^H]*)H(.*) $1h$2
rewriterule ([^I]*)I(.*) $1i$2
rewriterule ([^J]*)J(.*) $1j$2
rewriterule ([^K]*)K(.*) $1k$2
rewriterule ([^L]*)L(.*) $1l$2
rewriterule ([^M]*)M(.*) $1m$2
rewriterule ([^N]*)N(.*) $1n$2
rewriterule ([^O]*)O(.*) $1o$2
rewriterule ([^P]*)P(.*) $1p$2
rewriterule ([^Q]*)Q(.*) $1q$2
rewriterule ([^R]*)R(.*) $1r$2
rewriterule ([^S]*)S(.*) $1s$2
rewriterule ([^T]*)T(.*) $1t$2
rewriterule ([^U]*)U(.*) $1u$2
rewriterule ([^V]*)V(.*) $1v$2
rewriterule ([^W]*)W(.*) $1w$2
rewriterule ([^X]*)X(.*) $1x$2
rewriterule ([^Y]*)Y(.*) $1y$2
rewriterule ([^Z]*)Z(.*) $1z$2
No comments:
Post a Comment