mod_rewrite - simple I'm sure...

I need to rewrite the URL: www.something.com/gilmanciocia/opportunity/johndoe

to: www.something.com/gilmanciocia/opportunity/index.php?name=johndoe

My latest attempt doesn't work but I've never done this before and I'm half guessing:

<IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteRule ^gilmanciocia/opportunity/([A-Za-z]+)$ gilmanciocia/opportunity/index.php?name=$1
</IfModule>


LVL 1
sblissAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

caterham_wwwCommented:
You're using the rules in a /.htaccess (=root)?

remove the '<IfModule mod_rewrite.c>', this hides usefull errors, if the module isn't loaded.

Did you check in your httpd.conf, if AllowOverride is set to FileInfo (-> AllowOverride FileInfo), otherwise you cannot use mod_rewrite in a .htaccess file (if you did so). You can also try a local URL

RewriteEngine on
RewriteRule ^gilmanciocia/opportunity/([A-Za-z]+)$ /gilmanciocia/opportunity/index.php?name=$1 [L]

and if you're using the rules in your httpd.conf (per-server context), you must use

RewriteEngine on
RewriteRule ^/gilmanciocia/opportunity/([A-Za-z]+)$ /gilmanciocia/opportunity/index.php?name=$1 [L]


A simple mod_rewrite availability test would be

RewriteEngine on
RewriteRule ^ http://www.google.com [R,L]

you should see google.com for every request. If you're using it in a .htaccess file and if you get a 404, AllowOverride FileInfo is missing.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sblissAuthor Commented:
I did indeed have to set AllowOverride FileInfo and changing the rule to:

RewriteRule ^/gilmanciocia/opportunity/([A-Za-z]+)$ /gilmanciocia/opportunity/index.php?name=$1 [L]

did the trick. What's the [L] and [R] for?

Thanks for your quick and accurate response.
caterham_wwwCommented:
L means last, rules below aren't checked anymore
R forces an external redirection with HTTP status code 302 (moves temp.), so the URl will change in the location bar

AllowOverride... so you're using it in a .htaccess file. Usually there is no leading slash in the pattern (left side) of the RewriteRule. hm...
sblissAuthor Commented:
This is on my MacMini in my studio. I use it as a development server and I provide client access through a free IP service...if that somehow explains the leading slash.

The bottom line is it works... and thanks again.

Steve
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.