rewrite issue

accassar

Active Member
#1
url: http://test.com/category/library

results in PHP 'no input file specified error'

url: http://test.com/index.php/category/library works

.htaccess rewrite rules:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

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

<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</IfModule>

<IfModule mod_rewrite.c>
RewriteRule "(^|/)\." - [F]
</IfModule>

logs:

2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] strip base: '/' from URI: '/category/library'
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'category/library' with pattern '^(.*)$', result: 2
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Cond: Match '/category/library' with pattern '^system.*', result: -1
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'category/library' with pattern '^(.*)$', result: 2
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Cond: Match '/category/library' with pattern '^application.*', result: -1
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'category/library' with pattern '^(.*)$', result: 2
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] stat( /clientdata/apache-www/s/h/test.com/www/category ) failed
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] stat( /clientdata/apache-www/s/h/test.com/www/category ) failed
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Source URI: 'category/library' => Result URI: 'index.php/category/library'
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Last Rule, stop!
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] prepend rewrite base: '/', final URI: '/index.php/category/library'
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] strip base: '/' from URI: '/index.php/category/library'
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'index.php/category/library' with pattern '^(.*)$', result: 2
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Cond: Match '/index.php/category/library' with pattern '^system.*', result: -1
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'index.php/category/library' with pattern '^(.*)$', result: 2
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Cond: Match '/index.php/category/library' with pattern '^application.*', result: -1
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'index.php/category/library' with pattern '^(.*)$', result: 2
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Cond: test '/clientdata/apache-www/s/h/test.com/www/index.php' with pattern '-f', result: 0
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'index.php/category/library' with pattern '^(.*)$', result: 2
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Cond: Compare 'off' with pattern 'on', result: -1
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Cond: Match 'test.com' with pattern '^www\.(.+)$', result: -1
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'index.php/category/library' with pattern '(^|/)\.', result: -1
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] strip base: '/' from URI: '/index.php/category/library'
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'index.php/category/library' with pattern '^(.*)$', result: 2
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Cond: Match '/index.php/category/library' with pattern '^system.*', result: -1
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'index.php/category/library' with pattern '^(.*)$', result: 2
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Cond: Match '/index.php/category/library' with pattern '^application.*', result: -1
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'index.php/category/library' with pattern '^(.*)$', result: 2
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Cond: test '/clientdata/apache-www/s/h/test.com/www/index.php' with pattern '-f', result: 0
2012-04-27 15:47:48.472 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'index.php/category/library' with pattern '^(.*)$', result: 2
2012-04-27 15:47:48.473 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Cond: Compare 'off' with pattern 'on', result: -1
2012-04-27 15:47:48.473 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Cond: Match 'test.com' with pattern '^www\.(.+)$', result: -1
2012-04-27 15:47:48.473 [INFO] [127.0.0.1:33137-0#test.com] [REWRITE] Rule: Match 'index.php/category/library' with pattern '(^|/)\.', result: -1
 

NiteWave

Administrator
#2
how about change
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

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

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

accassar

Active Member
#3
Thanks that worked. Why doesn't it work with the '/' but with the '?' ?

I have a large number of virtualhosts to convert and am worried about little rewrite issues like this.
 
Top