Forum Moderators: coopster

Message Too Old, No Replies

PHP Rewrite Problem

unable to pass parameters

         

Arsen

2:33 pm on Jun 14, 2009 (gmt 0)

10+ Year Member



Hi,

Here is my .htaccess file content:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^news/([0-9][0-9])/(.*)$ /$2?id=$1 [L,QSA]
</IfModule>

I want to rewrite
www.example.com/news/55/test.php to www.example.com/test.php?id=55

It works perfect on my local machine but when I put the same thing on the server, I get
www.example.com/test.php?PHPSESSID=12121... instead of my passed parameter.

I guess there is some option or config which is not set properly on my server machine.

Any ideas?

Thanks in advance.

--
Arsen

g1smd

2:38 pm on Jun 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What URL is in the <a href...> of the link that was clicked?

Arsen

2:47 pm on Jun 14, 2009 (gmt 0)

10+ Year Member



www.example.com/news/55/test.php should be changed to www.example.com/test.php?id=55 with the rewrite rule.

I think the problem is not in the RewriteRule itself but it's some config issue, which not allows to rewrite engine to pass parameters.

g1smd

2:55 pm on Jun 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




What URL is in the <a href...> of the link that was clicked?

Arsen

4:03 pm on Jun 14, 2009 (gmt 0)

10+ Year Member



www.example.com/news/55/test.php

g1smd

4:36 pm on Jun 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What happens if you remove the [QSA] flag?

Arsen

4:44 pm on Jun 14, 2009 (gmt 0)

10+ Year Member



Nothing changes :s

g1smd

5:25 pm on Jun 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do you have any:
- redirects using RewriteRule listed after this rewrite, or,
- any redirects using Redirect or RedirectMatch at all?

Arsen

5:43 pm on Jun 14, 2009 (gmt 0)

10+ Year Member



I've put .htaccess file and only the following in it
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^news$ /news.php?lk=4 [R=301,QSA]
</IfModule>

I don't know if there are others in apache configs. How can I check that ?

Thanks for the replies

g1smd

6:18 pm on Jun 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What is the purpose of this latest code example?

It generates a 301 redirect, and re-appends the original query string.

jdMorgan

7:42 pm on Jun 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check that the MultiView option is disabled, and that AcceptPathInfo is off on the problematic server. If not, try turning them off in your .htaccess file.

Jim

Arsen

7:57 pm on Jun 14, 2009 (gmt 0)

10+ Year Member



<IfModule mod_rewrite.c>
Options -MultiViews
AcceptPathInfo Off
RewriteEngine on
RewriteBase /
RewriteRule ^news$ /news.php?lk=4 [L,QSA]
</IfModule>

Problem stays :(