Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm busy migrating a production codeigniter project to a new server. The current setup has been working fine for almost a year now but while moving to the new LAMP stack I'm running into a weird problem with rewriting the index.php back into the URL.

My initial thought was that this question would be better suited to SO however the code is exactly the same between the two instances and both are running Debian 7.5 and Apache 2.2.22 which makes me think it's a server config difference that I'm not aware of.

This is the mod_rewrite is as follows

RewriteEngine On
RewriteBase /bookings/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Like I said this has been working fine in the current setup however on the new server links from the base page always are rewritten to the same page.

I turned rewrite logging on for both servers and the new server is doing an extra rewrite step that I cannot explain.

Current server:

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

New server:

### 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

As can be seen above, the new server is doing the initial redirect correctly but then there's the extra section that always returns index.php. Any idea what could be causing this? I'm not even 100% sure that they problem is with mod_rewrite. I've run out of options and I don't know much about mod_rewrite

share|improve this question

1 Answer 1

I have no idea what caused this but I reimaged the server, reinstalled the services and the problem went away.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.