How can I redirect URLs with htaccess
×


How can I redirect URLs with htaccess

43754

.htaccess is used on the webserver which is running Apache Web Server Software. It is a configuration file.

It is used to alter the configuration i.e. to enable or disable the additional functionality and also features that are offered by the Apache Web Server Software.

For example, if you want to redirect the website to a particular link then you should write the below code in your .htaccess file


Redirect to same website file

Redirect /path/old.html  /path/new.html

Redirect to an external website

Redirect /path/old.html  http://www.website-name.com/path/new.html


Redirect error message (404 errors)

ErrorDocument 404 http://website-name.com/

Add www in URL

RewriteEngine On RewriteCond %{HTTP_HOST} ^website-name.com RewriteRule (.*) http://www.website-name.com/$1 [R=301,L]

How to remove www in URL

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

.htaccess topics:



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments