I am trying to redirect multiple domains to a single domain (which is working fine) but i want one directory to not redirect or change the main domain url.
here is my .htaccess code it works fine until here
this one is working
<pre>
RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.net$ [OR]
RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.org$ [OR]
RewriteCond %{HTTP_HOST} ^domain.info$ [OR]
RewriteCond %{HTTP_HOST} !^www.domain.info
RewriteRule (.*) http://www.domain.info/$1 [R=301,L]
</pre>
but when i try to stop redirect of one specific directory by
full code
<pre>
RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.net$ [OR]
RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.org$ [OR]
RewriteCond %{HTTP_HOST} ^domain.info$ [OR]
RewriteCond %{HTTP_HOST} !^www.domain.info [OR]
RewriteCond %{REQUEST_URI} !^/no_redirect_dir/
RewriteRule (.*) http://www.domain.info/$1 [R=301,L]
</pre>
it all stops working :( with an error that page is not redirecting correctly.
extra code causing error
<pre>
RewriteCond %{HTTP_HOST} !^www.domain.info [OR]
RewriteCond %{REQUEST_URI} !^/no_redirect_dir/
</pre>
any help would be highly appreciated.
thank you!
How to redirect all pages to another domain using .htaccess: Set the nameservers of the old domain to somewhere you have cPanel hosting; Go into cPanel and add the old domain; Add a .htaccess file that 301 redirects all the internal pages to the new domain; Add a blank index.php for extra safety.
In order to redirect your old domain to a new domain name, you should add the following rewrite rule to your .htaccess file: In order to redirect your site from a non-www to www URL, you should add the following rewrite rule to your .htaccess file:
When you need to switch a website from an old domain to a new domain, you need to redirect all your page URLs, this is when htaccess is your friend. The code below will create 301 url redirects for both the www and non-www version of ‘ olddomain.com ‘ to the new domain ‘ newdomain.com ‘.
To redirect the contents of a whole directory to the webserving root: To redirect the contents of a subdirectory to another domain but in the same subdirectory Make sure that the opening of the .htaccess file contains the 2 lines of code below which enables the Apache module to rewrite the URLS, then place your redirections below them
Write your .htaccess like this:
RewriteCond %{HTTP_HOST} (www\.)?domain\.(org|net|com)$ [NC]
RewriteCond %{REQUEST_URI} !^/*no_redirect_dir/ [NC]
RewriteRule ^(.*)$ http://www.domain.info/$1 [R=301,L]
HTTP_HOST variable just has domain name, no http/https information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With