301 .htaccess domain redirect on Litespeed - Blog - General Coding Tips for Web Design

GJC Website Design UK, Joomla Developer, VirtueMart Developer, Template Developer, web site designs, England, Britain, UK, Belgium, search-engine optimisation (SEO). Multilingual.

Home Blog 301 .htaccess domain redirect on Litespeed

Sun

22

Mar

301 .htaccess domain redirect on Litespeed

The standard Apache 301 domain redirect ( page to page after a domain change) gives a 404 on Litespeed after the redirection.

It needs two additional?RewriteCond to make it work.

Click further to read how.

 

The standard Apache .htaccess code is:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ https://domainnew.com/$1 [R=301,L]
</IfModule>

But this will cause all pages to be 404's on the new domain if you are using Litespeed as your server.

As an example if you are changing your domain name from domainold.com to domainnew.com and want to redirect each old page to it's new one then you need to only Rewrite the old domain as follows:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domainold.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domainold.com [NC]
RewriteRule ^(.*)$ https://domainnew.com/$1 [R=301,L]
</IfModule>


Last Updated on Saturday, 22 January 2022 12:12
 



301 .htaccess domain redirect on Litespeed|Blog | General Coding Tips for Web Design



GJC Website Design UK, Joomla Developer, VirtueMart Developer, Template Developer, web site designs, England, Britain, UK, Belgium, search-engine optimisation (SEO). Multilingual.


domain, page, domainnew, domainold, rewritecond, https, rewriterule, old, host, http, standard, rewriteengine, litespeed, redirect, apache, example, changing, gives, follows, www, change, server, rewrite, using, work, click, read, code, additional, needs, pages, cause, redirection, htaccess


guru

We use cookies to improve our website and your experience when using it. Cookies used for the essential operation of the site have already been set.
To find out more about the cookies we use and how to delete them, see our privacy policy.

I accept cookies from this site.