【问题标题】:How to exclude a specific folder in htaccess如何在 htaccess 中排除特定文件夹
【发布时间】:2016-04-28 12:21:14
【问题描述】:

当用户点击时

此链接我的 htaccess 正在运行。

但是当用户点击时

我的网站重定向到

因为我的网站在我的目录结构中包含文件夹 2。

当用户点击时

我的 htaccess 应该忽略这个 URL,因为我想将用户重定向到文件夹 2 中的 index.php

下面编写的代码存在于我的 htaccess 文件中

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

我该怎么办? 请帮我解决这个问题。

【问题讨论】:

  • 这个 htaccess 在哪里?

标签: php .htaccess mod-rewrite url-rewriting


【解决方案1】:

假设您要排除文件夹 'exclude_me' 。 添加

RewriteCond %{REQUEST_URI} !^/exclude_me/.*$

对我有用

【讨论】:

  • 当我点击 localhost/mywebsite/exclude_me 时,它​​会重定向到 localhost/exclude_me
  • 并且说对象没有被污染
【解决方案2】:

试试这个:

重写引擎开启

重写规则 ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_URI}!^/excluded-folder/

RewriteCond %{REQUEST_FILENAME} !-f

重写规则 ^ index.php [L]

【讨论】:

    猜你喜欢
    • 2015-12-11
    • 2011-07-08
    • 2013-07-17
    • 2011-05-04
    • 2011-01-16
    • 2012-11-30
    • 2013-10-27
    • 1970-01-01
    • 2022-12-14
    相关资源
    最近更新 更多