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

时间秒杀一切 提交于 2019-12-25 06:44:53

问题


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
    </IfModule>

    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]
</IfModule>

10x very much! hope anybody can help me.


回答1:


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

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


来源:https://stackoverflow.com/questions/39062158/htaccess-mod-rewrite-how-to-exclude-addon-domain-from-rewrite-rule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!