重定向所有但不是从特定文件夹或其子文件夹.htaccess

时间:2014-02-19 08:51:40

标签: php .htaccess mod-rewrite redirect codeigniter-2

我编写了以下htaccess重写来将任何请求重定向到名为index.php的维护页面

  RewriteEngine On
  RewriteCond %{REQUEST_URI} !=/index.php
  RewriteRule .* /index.php

现在我想要一个我正在修复开发文件的文件夹,从上面的通用重定向中排除到index.php。我该怎么写这个条件。我已经这样做了:

 RewriteCond  %{REQUEST_URI} !=/xxxxxxxx-xxxx-xxx-xx/ 
 ### here xxxxxx-is the folder name

我的xxxxxx文件夹中的htaccess从url中排除'index.php'以使网址看起来很漂亮,但现在它在服务器上提供了404

 # Turn on URL rewriting
 RewriteEngine On

 # If your website begins from a folder e.g localhost/my_project then
 # you have to change it to: RewriteBase /my_project/
 # If your site begins from the root e.g. example.local/ then
 # let it as it is
 RewriteBase /xxxxxxxxx/

 # Protect application and system files from being viewed when the index.php is missing
 RewriteCond $1 ^(application|system|private|logs)

 # Rewrite to index.php/access_denied/URL
 RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

 # Allow these directories and files to be displayed directly:
 RewriteCond $1        ^(index\.php|robots\.txt|favicon\.ico|public|assets|resources|css|js|images)

 # No rewriting
 RewriteRule ^(.*)$ - [PT,L]

 # Rewrite to index.php/URL
 RewriteRule ^(.*)$ index.php/$1 [PT,L]

1 个答案:

答案 0 :(得分:0)

您可以使用:

RewriteEngine On

RewriteCond %{REQUEST_URI} !/(index.php|excluded-folder/) [NC]
RewriteRule ^ /index.php [L]