How can I redirect URLs with htaccess
0 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:
- deny direct access to folder in website with .htaccess
- remove index.php from URL with .htaccess
- How remove .php extension with .htaccess
Share:
Comments
Waiting for your comments