Udi H. Keller Udi H. Keller - 3 months ago 13
Apache Configuration Question

.htaccess mod_rewrite - how to exclude addon domain from rewrite rule?

my main hosting domain require ssl, so the htaccess transform every url request to https.

but i have on the same hosting another domain, with cpanel dir structure ("public_htmml/addon-domain.com")

The public_html htaccess is the only I can configure. I need to exclude from the rewrite the directory of the add-on domain. so when a user type www.addondoamin.com or without the www, the htaccess will not do anything. o/w, i get many errors and the addon domain mirror to the main domain.

notice that

RewriteCond %{REQUEST_URI} !^/public_html/addon-domain.com/.*$

didnt work.

So, here is the htaccess.

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !promotion
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

10x very much! hope anybody can help me.


How about this which can be placed anywhere above your current rules:

RewriteCond %{HTTP_HOST} ^(www\.)?addon-domain\.com$
RewriteRule ^.*$ '-' [L]