服务器移动后,mod_rewrite停止工作

时间:2013-04-28 17:09:58

标签: apache .htaccess mod-rewrite

这是我的.htaccess文件

## Turn on RewriteEngine
RewriteEngine on
Options +FollowSymlinks

## Ignore
RewriteRule     (slir)  -   [L,NC]
RewriteRule     ^slir - [L,NC]

## CakePHP
RewriteRule     ^$      app/webroot/    [L]
RewriteRule     (.*)    app/webroot/$1  [L]

这曾经在我的旧主机上正常工作,但自从转移到HostGator后,#ignore下的两条规则已停止工作。只有两个因为我正在尝试不同的事情。

基本上所有请求都会发送到app / webroot,但我有一个名为“slir”的文件夹,我希望将其排除在此之外。

后两条规则如何运作但前两条规则已停止工作?

感谢。

3 个答案:

答案 0 :(得分:0)

您可以使用重写标记skip。如果我们找到匹配项,则跳过以下重写规则:

RewriteEngine on
Options +FollowSymlinks

# If we have a match for slir anywhere in the REQUEST_URI
# (case insensitive based on NC in supplied code)
RewriteCond %{REQUEST_URI} [sS][Ll][Ii][Rr]
# then skip 1 rule.
RewriteRule .? - [S=1]
#Match 0 or any character + and rewrite the URL.
RewriteRule ^(.*)$ app/webroot/$1 [L]

答案 1 :(得分:0)

你可以试试这个:

RewriteEngine on
RewriteBase /
Options +FollowSymlinks

# Send all requests that do not start with `/slir` to the webroot.
RewriteCond %{REQUEST_URI} !^/slir
RewriteRule ^(.*)$ app/webroot/$1 [L]

答案 2 :(得分:0)

最后是因为/ slir /中的htaccess文件有这个:

# Prevent other scripts from interfering with SLIR
php_value auto_prepend_file none
php_value auto_append_file none

评论两行后,问题就消失了

相关问题