Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewrite Help

Could anyone help me with a mod rewrite rule please.

         

vancer

9:18 am on Nov 21, 2007 (gmt 0)

10+ Year Member



I need to take a URL query string and remove the forward slash (/) that is after the test.php.

Example:

cpc/test.php/?pid=1&showlogo=1&listings=10&searchstring=golf+balls

So that the query string becomes:

cpc/test.php?pid=1&showlogo=1&listings=10&searchstring=golf+balls

Any help appreciated.

Regards
Vance

jdMorgan

3:13 pm on Nov 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This problem is not as difficult as it seems, because query strings are handled separately by mod_rewrite.

Assuming you already have other working mod_rewrite code, it's simply a matter of removing the slash from test.php/


RewriteRule ^test\.php/$ http://www.example.com/test.php [R=301,L]

The query string will pass through this rule unchanged.

Jim

vancer

4:14 pm on Nov 21, 2007 (gmt 0)

10+ Year Member



Hi Jim

Thanks for your help but it still won't work.

Here's an actual example:

http://www.example.com/cpc/clickandcall_js.php/?pid=1&showlogo=1&listings=10&searchstring=golf+balls

This produces an error but if I remove the slash then it works fine.

Here is the rule I've tried.

RewriteRule ^clickandcall_js\.php/$ http://www.example.com/cpc/clickandcall_js.php [R=301,L]

[edited by: jdMorgan at 4:24 pm (utc) on Nov. 21, 2007]
[edit reason] example.com [/edit]

jdMorgan

12:25 am on Nov 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You put the .htaccess code in /cpc/.htaccess, right?

Also be sure there are no other rules in /.htaccess or /cpc/.htaccess that conflict with this one. Since you did not say what kind of error you got, or what you saw in your server error log, that's all I can come up with right now.

Jim

vancer

9:25 am on Nov 22, 2007 (gmt 0)

10+ Year Member



Thanks again Jim.

The error message is:

No input file specified.

Regards
Vance

[edited by: jdMorgan at 12:40 pm (utc) on Nov. 22, 2007]
[edit reason] No URLs please. See Terms of Service. [/edit]