简体   繁体   中英

Ignore directory in RewriteRule - .htaccess

I searched in internet for this, found alot of solutions but none of them worked.

I am using shared hosting and in this hosting all the websites data are in one public_html folder.

I have .htaccess file in public_html folder which is for my main site named "mainexample.com" and all the other websites have folders named according to their domain. eg "example1.com" and "example2.com".

I want to ignore these "example1.com" and "example2.com" folder only.

Below is my .htaccess code.

<IfModule mod_rewrite.c>

# index file can be index.php, home.php, default.php etc.
DirectoryIndex index.php

# Rewrite engine
RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule .* https://www.mainexample.com%{REQUEST_URI} [R,L]

# condition with escaping special chars
RewriteBase /

RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

将此规则插入RewriteEngine On行下面以忽略所选文件夹:

RewriteRule ^(example1|example2)\.com(/|$) - [L,NC]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM