Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

redirect all to another url except specific folder(s) and subdomain(s)

presently I have my htaccess redirecting everything to another URL, unless it is in the forums folder...

RewriteEngine On
RewriteCond %{REQUEST_URI} !/Forum
RewriteRule ^.*$ http://www.newsite.com/ [R=301]

I have set up a sub-domain in my original site, using a folder called subdomain.

what I would like to do is retain my existing redirect, and prevent redirects of my subdomain

like image 761
craigr Avatar asked Feb 02 '26 21:02

craigr


1 Answers

You should be able to combine your !/Forum condition with a new one, as follows:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(Forum|subdomain)
RewriteRule ^.*$ http://www.newsite.com/ [R=301]

That uses a regular expression which will match either "/Forum" or "/subdomain".


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!