ModRewrite

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

ModRewrite

Post by GeXus »

I have the following modrewrite...

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)/$ ?name=$1 [nc]

I want to a few more parameters, such as:

RewriteRule ^(.*)/(.*)/(.*)/(.*)$ ?name=$1&ab=$2&cd=$3&ef=$4 [nc]

This doesn't seem to be working though. If I only have one parameter populated, then it doesn't work - 404.

Any ideas? There won't always be 4 values, but there will always be the first one.
User avatar
Kastor
Forum Newbie
Posts: 24
Joined: Thu May 01, 2008 2:29 am
Location: Grodno, Belarus
Contact:

Re: ModRewrite

Post by Kastor »

:wink:
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)$ ?name=$1&ab=$2&cd=$3&ef=$4
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Re: ModRewrite

Post by GeXus »

Hmm.. I get the same problem, if I only use the first value (i.e., http://www.domain.com/something/) it returns 404
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Re: ModRewrite

Post by GeXus »

This works...

RewriteRule ^([^/]+)(?:/([^/]+)(?:/([^/]+)(?:/([^/]+))?)?)?/?$ /?name=$1&ab=$2&cd=$3&ef=$4 [QSA,L]
Post Reply