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

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

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

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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
Post Reply