Problem with URL with multiple variables

Discuss practical ways rearrange URLs using mod_rewrite.

Problem with URL with multiple variables

Postby sops21 » Mon Sep 22, 2008 12:18 am

I have a problem.

I have a url that goes as following.

Code: Select all
/video/viewchannel-testing.php?curlname=videoone&pagenumber=2


I'm using the following rule to accomplish this:

Code: Select all
RewriteRule ^testchannel/([^/\.]*)/([^/\.]*)/?$ /video/viewchannel-testing.php?curlname=$1&pagenumber=$2 [L]


This almost works.
I have one problem:
/videochannel/videochannelnamehere/

works, as well as
videochannel/videochannelnamehere/2

and
videochannel/videochannelnamehere/2/

works, however

/videochannel/videochannelnamehere

without the "/" at the end does not work, it 404's.

What do I need to change in the rule to make it work?
sops21
 
Posts: 1
Joined: Mon Sep 22, 2008 12:07 am

Postby richardk » Tue Sep 23, 2008 11:36 am

It is because there are two "/"s in the pattern (not including the /? at the end).

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^testchannel/([^/\.]+)(?:/([0-9]+))?/?$ /video/viewchannel-testing.php?curlname=$1&pagenumber=$2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 26 guests

cron