You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Mistery <mi...@fastwebnet.it> on 2004/05/15 15:21:00 UTC

[users@httpd] url rewriting question

Hi all,

i'm trying to configure a rewiting rule to translate the url
http://www.mysite.com/dir/page[,param] into
http://www.mysite.com/index.php?d=dir&p=page&s=param where dir may be any
string except "user" and "admin" and param is optional

I tried the following rule with no success:

RewriteRule
/([^/|^(user)|^(admin)]+)/([^/]+)[\,]?([^/]*)/([^/]+)[\,]?([^/]*)
/index.php?t=$1&s=$2&p=$3 [L]

I hope someone might be able to help me.

Many tnx!
Mistery




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] url rewriting question

Posted by Joshua Slive <jo...@slive.ca>.
On Sat, 15 May 2004, Mistery wrote:

> Hi all,
>
> i'm trying to configure a rewiting rule to translate the url
> http://www.mysite.com/dir/page[,param] into
> http://www.mysite.com/index.php?d=dir&p=page&s=param where dir may be any
> string except "user" and "admin" and param is optional
>
> I tried the following rule with no success:
>
> RewriteRule
> /([^/|^(user)|^(admin)]+)/([^/]+)[\,]?([^/]*)/([^/]+)[\,]?([^/]*)
> /index.php?t=$1&s=$2&p=$3 [L]

To start with, you can't do negatives in that way.  The [] contain
character classes, not strings.  To do negatives, preceed the RewriteRule
with
RewriteCond %{REQUEST_URI} !^/user

Second, I don't believe you need to backslash-escape the "," in a
character class.  Third, your regex seems to be more complicated than your
requirement suggests.  Are you trying to deal with multiple levels of
directories?

To sum up, I'd start with something like:

RewriteCond %{REQUEST_URI} !^/user
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule ^/([^/]+)/([^/,]+),?(.*) /index.php?t=$1&s=$2&p=$3

(This is not tested, but it is much closer than what you have.)

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org