I have a URL that is being generated using GET variables from a form in PHP. The issue that I have is that there are two variables being passed. Here is an example URL to clarify:
http://www.examplesite.com/example.php?first=one&second=two
I would like to use a mod_rewrite in my .htaccess to make this a smaller URL. Ideally I would like the URL...
http://www.examplesite.com/one
to be able to redirect to the full URL...
http://www.examplesite.com/example.php?first=one&second=two
but as you can see there are two variables. Is this possible? If not, what is the shortest that I can get the URL using both variables?
Here is my current attempt to solve this with a mod_rewrite
RewriteEngine on
# don't rewrite if the file exists
RewriteCond %{REQUEST_FILENAME} !-f
# don't rewrite if the directory exists
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ example.php?first=$1&second=$2
Try this:
RewriteEngine on
# don't rewrite if the file exists
RewriteCond %{REQUEST_FILENAME} !-f
# don't rewrite if the directory exists
RewriteCond %{REQUEST_FILENAME} !-d
# http://www.examplesite.com/one/two
RewriteRule ^([^/]*)/([^/]*)$ /example.php?first=$1&second=$2 [L]