duandu8892
duandu8892
2015-05-09 18:20

忽略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. e.g. "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>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • doudiecai1572 doudiecai1572 6年前

    Insert this rule just below RewriteEngine On line to ignore selected folders:

    RewriteRule ^(example1|example2)\.com(/|$) - [L,NC]
    
    点赞 评论 复制链接分享

相关推荐