Page 1 of 1

.htaccess with $1 and $2 doesn't work

Posted: Tue May 01, 2007 3:48 pm
by thiscatis

Code: Select all

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/img/.*
RewriteRule ^([A-Za-z0-9]+)$ /$1/ [R]
RewriteRule ^([A-Za-z0-9]+)/$ /index.php?page=$1
This works but

Code: Select all

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/img/.*
RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+)$ /$1/$2/ [R]
RewriteRule ^([A-Za-z0-9]+)/([A-Za-z]+)/?$ /index.php?page=$1&plugin=$2

If i enter:
myurl.com/welcome/search/ >> works
myurl.com/welcome/ >> doesn't work anymore if I use the second htaccess content

Posted: Tue May 01, 2007 6:24 pm
by RobertGonzalez
You need to make accommodations for the potential of one parameter after the two parameter one.

Code: Select all

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/img/.*
RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+)$ /$1/$2/ [R]
RewriteRule ^([A-Za-z0-9]+)/([A-Za-z]+)/?$ /index.php?page=$1&plugin=$2
RewriteRule ^([A-Za-z0-9]+)$ /$1/ [R]
RewriteRule ^([A-Za-z0-9]+)/$ /index.php?page=$1