我正忙着将生产codeigniter项目迁移到新服务器。目前的设置已经运行了近一年了但是在转移到新的LAMP堆栈时,我遇到了一个奇怪的问题,将index.php重写回URL。
这是mod_rewrite如下
RewriteEngine On
RewriteBase /bookings/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
就像我说的那样,在当前的设置中一直运行良好,但是从基页的新服务器链接总是被重写到同一页面。两台服务器都运行Debian 7.5和Apache 2.2.22
我为两台服务器改为重写登录,新服务器正在进行额外的重写步骤,我无法解释。
当前服务器:
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5c45350a0/initial] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] add path info postfix: /var/www/vhosts/domain.tld/html/bookings/school -> /var/www/vhosts/domain.tld/html/bookings/school/event/1
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5c45350a0/initial] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] strip per-dir prefix: /var/www/vhosts/domain.tld/html/bookings/school/event/1 -> school/event/1
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5c45350a0/initial] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] applying pattern '^(.*)$' to uri 'school/event/1'
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5c45350a0/initial] (4) [perdir /var/www/vhosts/domain.tld/html/bookings/] RewriteCond: input='/var/www/vhosts/domain.tld/html/bookings/school' pattern='!-f' => matched
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5c45350a0/initial] (4) [perdir /var/www/vhosts/domain.tld/html/bookings/] RewriteCond: input='/var/www/vhosts/domain.tld/html/bookings/school' pattern='!-d' => matched
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5c45350a0/initial] (2) [perdir /var/www/vhosts/domain.tld/html/bookings/] rewrite 'school/event/1' -> 'index.php/school/event/1'
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5c45350a0/initial] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] add per-dir prefix: index.php/school/event/1 -> /var/www/vhosts/domain.tld/html/bookings/index.php/school/event/1
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5c45350a0/initial] (2) [perdir /var/www/vhosts/domain.tld/html/bookings/] trying to replace prefix /var/www/vhosts/domain.tld/html/bookings/ with /bookings/
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5c45350a0/initial] (5) strip matching prefix: /var/www/vhosts/domain.tld/html/bookings/index.php/school/event/1 -> index.php/school/event/1
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5c45350a0/initial] (4) add subst prefix: index.php/school/event/1 -> /bookings/index.php/school/event/1
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5c45350a0/initial] (1) [perdir /var/www/vhosts/domain.tld/html/bookings/] internal redirect with /bookings/index.php/school/event/1 [INTERNAL REDIRECT]
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5b3e057c8/initial/redir#1] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] add path info postfix: /var/www/vhosts/domain.tld/html/bookings/index.php -> /var/www/vhosts/domain.tld/html/bookings/index.php/school/event/1
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5b3e057c8/initial/redir#1] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] strip per-dir prefix: /var/www/vhosts/domain.tld/html/bookings/index.php/school/event/1 -> index.php/school/event/1
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5b3e057c8/initial/redir#1] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] applying pattern '^(.*)$' to uri 'index.php/school/event/1'
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5b3e057c8/initial/redir#1] (4) [perdir /var/www/vhosts/domain.tld/html/bookings/] RewriteCond: input='/var/www/vhosts/domain.tld/html/bookings/index.php' pattern='!-f' => not-matched
105.237.x.x - - [16/May/2014:09:45:11 +0200] [www.domain.tld/sid#7fd5c46fbfc8][rid#7fd5b3e057c8/initial/redir#1] (1) [perdir /var/www/vhosts/domain.tld/html/bookings/] pass through /var/www/vhosts/domain.tld/html/bookings/index.php
新服务器:
### First section is identical ###
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673240a0/initial] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] add path info postfix: /var/www/vhosts/domain.tld/html/bookings/school -> /var/www/vhosts/domain.tld/html/bookings/school/event/1
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673240a0/initial] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] strip per-dir prefix: /var/www/vhosts/domain.tld/html/bookings/school/event/1 -> school/event/1
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673240a0/initial] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] applying pattern '^(.*)$' to uri 'school/event/1'
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673240a0/initial] (4) [perdir /var/www/vhosts/domain.tld/html/bookings/] RewriteCond: input='/var/www/vhosts/domain.tld/html/bookings/school' pattern='!-f' => matched
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673240a0/initial] (4) [perdir /var/www/vhosts/domain.tld/html/bookings/] RewriteCond: input='/var/www/vhosts/domain.tld/html/bookings/school' pattern='!-d' => matched
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673240a0/initial] (2) [perdir /var/www/vhosts/domain.tld/html/bookings/] rewrite 'school/event/1' -> 'index.php/school/event/1'
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673240a0/initial] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] add per-dir prefix: index.php/school/event/1 -> /var/www/vhosts/domain.tld/html/bookings/index.php/school/event/1
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673240a0/initial] (2) [perdir /var/www/vhosts/domain.tld/html/bookings/] trying to replace prefix /var/www/vhosts/domain.tld/html/bookings/ with /bookings/
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673240a0/initial] (5) strip matching prefix: /var/www/vhosts/domain.tld/html/bookings/index.php/school/event/1 -> index.php/school/event/1
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673240a0/initial] (4) add subst prefix: index.php/school/event/1 -> /bookings/index.php/school/event/1
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673240a0/initial] (1) [perdir /var/www/vhosts/domain.tld/html/bookings/] internal redirect with /bookings/index.php/school/event/1 [INTERNAL REDIRECT]
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f3367321b58/initial/redir#1] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] add path info postfix: /var/www/vhosts/domain.tld/html/bookings/index.php -> /var/www/vhosts/domain.tld/html/bookings/index.php/school/event/1
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f3367321b58/initial/redir#1] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] strip per-dir prefix: /var/www/vhosts/domain.tld/html/bookings/index.php/school/event/1 -> index.php/school/event/1
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f3367321b58/initial/redir#1] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] applying pattern '^(.*)$' to uri 'index.php/school/event/1'
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f3367321b58/initial/redir#1] (4) [perdir /var/www/vhosts/domain.tld/html/bookings/] RewriteCond: input='/var/www/vhosts/domain.tld/html/bookings/index.php' pattern='!-f' => not-matched
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f3367321b58/initial/redir#1] (1) [perdir /var/www/vhosts/domain.tld/html/bookings/] pass through /var/www/vhosts/domain.tld/html/bookings/index.php
### The extra redirect ###
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673220a0/initial] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] strip per-dir prefix: /var/www/vhosts/domain.tld/html/bookings/ ->
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673220a0/initial] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] applying pattern '^(.*)$' to uri ''
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673220a0/initial] (4) [perdir /var/www/vhosts/domain.tld/html/bookings/] RewriteCond: input='/var/www/vhosts/domain.tld/html/bookings/' pattern='!-f' => matched
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673220a0/initial] (4) [perdir /var/www/vhosts/domain.tld/html/bookings/] RewriteCond: input='/var/www/vhosts/domain.tld/html/bookings/' pattern='!-d' => not-matched
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f33673220a0/initial] (1) [perdir /var/www/vhosts/domain.tld/html/bookings/] pass through /var/www/vhosts/domain.tld/html/bookings/
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f336731c0a0/subreq] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] strip per-dir prefix: /var/www/vhosts/domain.tld/html/bookings/index.php -> index.php
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f336731c0a0/subreq] (3) [perdir /var/www/vhosts/domain.tld/html/bookings/] applying pattern '^(.*)$' to uri 'index.php'
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f336731c0a0/subreq] (4) [perdir /var/www/vhosts/domain.tld/html/bookings/] RewriteCond: input='/var/www/vhosts/domain.tld/html/bookings/index.php' pattern='!-f' => not-matched
105.237.x.x - - [16/May/2014:10:11:18 +0200] [www.domain.tld/sid#7f33674c04f0][rid#7f336731c0a0/subreq] (1) [perdir /var/www/vhosts/domain.tld/html/bookings/] pass through /var/www/vhosts/domain.tld/html/bookings/index.php
从上面可以看出,新服务器正在进行正确的初始重定向,但随后会有额外的部分始终返回index.php。知道是什么原因引起的吗?我甚至不能100%确定他们的问题是mod_rewrite。我的选项用完了,我对mod_rewrite
了解不多答案 0 :(得分:0)
我不知道是什么导致这种情况,但我重新构建了服务器,重新安装了服务,问题就消失了。