I am using the following code...
#Fix Rewrite
Options -Multiviews
# Mod Rewrite
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)?$ index.php?q=$1 [L]
to turn www.website.com/index.php?q=Keyword
into www.website.com/Keyword
Which works great....however....
I also (in the same directory) have a file called spec.php
which accepts a GET
variable of eid
.
I need to also have a rule that turns www.website.com/spec.php?eid=00000
into www.website.com/00000
or www.website.com/spec/00000
without actually moving spec.php
into a subdirectory.
Any help would be GREATLY appreciated, my eyes have google burn. I found some that did something similar but when I tried to match it to my situation I got problems.
So this line here
RewriteRule ^(.*)?$ index.php?q=$1 [L]
is matching everything, if you want to have website.com/Keyword
work and website.com/spec/0000
work then you need to add another condition
I think this will work
RewriteRule ^/spec/(.+)$ /spec.php?eid=$1 [L]
RewriteRule ^(.*)?$ /index.php?q=$1 [L]
What is this saying?
First part is a regular expression, second part is the URL to map it to and the last part is the flags. In this instance we put the /spec/
condition first so that it is hit first as the second condition will match everything else and then make sure the [L]
flag is set as that tells mod_rewrite to stop if the current condition matches.