I want the following redirection using 301 redirection:
from: http://www.hostingwebsitedomain.com
to: http://hostingwebsitedomain.com
Kindly guide how I can achieve this for all pages.
Thanks in advance!
I want the following redirection using 301 redirection:
from: http://www.hostingwebsitedomain.com
to: http://hostingwebsitedomain.com
Kindly guide how I can achieve this for all pages.
Thanks in advance!
From: https://datakoncepts.com/SEO
[quote]Eliminate www for a Domain
Going the other way (getting rid of the www prefix)?
RewriteEngine on
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule .? http://example.com%{REQUEST_URI} [R=301,L]
Get rid of the www but preserve a subdomain with:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?example\.com)$ [NC]
RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]
Here, the subdomain is captured in %2 (the inner atom) but, since it’s optional and already captured in the %1 Apache variable, all you need is the %1 for the subdomain and domain without the leading www.[/quote]
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.