over 9 years ago
Now question is that What is this mod_rewrite ?
mod_rewrite is an Apache module that allows for server-side manipulation of requested URLs.
Source: mod_rewrite
It is most common method of redirection to new website or URL. I personally recommend this method because here all the redirection handles at the server end. and same is re. Your htaccess file reside root folder of your website depending upon type of hosting and other factor it may be in your website's [public_html] or 'httpdocs'. Always save file as ".htaccess" not as 'htaccess.txt'. If you don't have one you can create with the help of any text editor like notepad .htaccess file. Make sure you save in same file in root folder.
- Options +FollowSymLinks RewriteEngine on</code>
- RewriteCond %{HTTP_HOST} ^www.OldWebsite.com$ [OR]
- RewriteCond %{HTTP_HOST} ^OldWebsite.com$
- RewriteRule ^(.*)$ http://www.newebsite.com/$1 [R=301,L]
Options +FollowSymLinks RewriteEngine on</code> RewriteCond %{HTTP_HOST} ^www.OldWebsite.com$ [OR] RewriteCond %{HTTP_HOST} ^OldWebsite.com$ RewriteRule ^(.*)$ http://www.newebsite.com/$1 [R=301,L]
Add the following code in .htaccess file to permanently redirect all the www addresses to their non www counterparts:
Replace xyz.com with name of your Website.
I have read many blog on Htaccess file redirection but I must admit that, I have never encounter proper explanation of the code and terms used htaccess redirect file. Finally I found it on some Blog Post(Link Given).
Source: htaccess Rewrite Rules
Hope This blog post / Tutorial on Apache htaccess redirect URL will help you. If You have any query on Apache, Do post on Apache Forum.
Apart from This if you have any Java language query, Do post at our Java Questions and Answers Forum.
Can you help out the community by solving one of the following Version Control problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)