4
votes

Last 2 days i'm trying to run some application on my computer (Ubuntu 11.10, Apache/2.2.20 (Ubuntu), PHP Version 5.3.6-13ubuntu3.1). It's created in PHP Smarty and it use rewrite rules. Everything works fine with links like:

localhost/news

it's correctly translated into

localhost/news.php 

how it should be done. But the problem is with more complicated links like

localhost/message/inbox

it should be translated with rule:

RewriteRule ^messages/(.*)$ /messages.php?action=$1

But it doesn't work. I was trying to debug it. I've truned on logging in http.conf

RewriteLog "/home/krzysztofp/rewrite.log"
RewriteLogLevel 3

And what i can see is that in the begining there is

127.0.0.1 - - [16/Mar/2012:15:56:36 +0100] [krzysztofp/sid#7f8218546a30][rid#7f821837a0a0/subreq] (3) [perdir /var/www/engbook/] add path info postfix: /var/www/engbook/messages.php -> /var/www/engbook/messages.php/inbox

and then it's trying to match message.php

127.0.0.1 - - [16/Mar/2012:15:56:36 +0100] [krzysztofp/sid#7f8218546a30][rid#7f821837a0a0/subreq] (3) [perdir /var/www/engbook/] applying pattern '^messages/(.*)$' to uri 'messages.php/inbox'

Virtual Host:

<Directory /var/www/engbook>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

any idea why it's happening?

EDIT: i have a problem to put all rewrite rules on stack so here they are: http://pokazkod.pl/d52823d5f0d31ff26e1e29873383d2a2ceb216306a56b3aec1 none on them look suspicious to me :/

1
please post your rewrite rules - scibuff
When you say it is not working, what do you mean? You get an error? You get the wrong page? The wrong output? I used your rules and when I go to /messages/inbox it calls messages.php?action=inbox just fine. - roychri
and that's what i would expect with there rules but somehow it calls just messages.php without ?action=inbox. In messages.php there is switch statment on $_GET['action'] and i can see that variable $_GET is empty... I think it's a problem with configuration of Apache but i can't find where the hell is it. - krzysiek
Probably a typo, but in your url you use message, and in you rewriterule messages (plural). Also adding RewriteEngine On could help. - Gerben
yes, it's just typo and ReWriteEngine On is already added in the begining .htaccess ... - krzysiek

1 Answers

8
votes

Try removing MultiViews

<Directory /var/www/engbook>
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>