This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Pages: [1]
1
Apache / 301 redirect
« on: June 25, 2017, 08:47:18 AM »
I have on several websites the following problem, how can i fix it for all the websites or individual websites ?
In order to pass this test you must consider using a 301 re-write rule in your .htaccess file so that both addresses
(http://example.com and http://www.example.com) resolve to the same URL.
- If you want to redirect http://www.example.com to http://example.com, you can use this:
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ "http\:\/\/example\.com\/" [R=301,L]
- If you want to redirect http://example.com to http://www.example.com, you can use this:
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Note that you must put the above lines somewhere after RewriteEngine On line.
In order to pass this test you must consider using a 301 re-write rule in your .htaccess file so that both addresses
(http://example.com and http://www.example.com) resolve to the same URL.
- If you want to redirect http://www.example.com to http://example.com, you can use this:
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ "http\:\/\/example\.com\/" [R=301,L]
- If you want to redirect http://example.com to http://www.example.com, you can use this:
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Note that you must put the above lines somewhere after RewriteEngine On line.
Pages: [1]