Rewriting with mod-rewrite

Need some help rewriting, with mod_rewrite, i cannot get the result i want even though I know it can be done and I just cannot understand the mod_rewrite stuff.

I am after something like the following

rewrite from www.domain.com/index.php?cPath=21
to www.domain.com/aprilia-parts/
and
rewrite from www.domain.com/index.php?cPath=22
to www.domain.com/ducati-parts/

can anyone help or maybe even post some example code to help.

Many thanks
LVL 12
ShaneJonesAsked:
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.

ravenplCommented:
I think it should be done within the index.php code, but if You insist on mod_rewrite
into the .htaccess

Option +FollowSymLinks
RewriteEngin On
RewriteCond %{QUERY_STRING} ^cPath=21$
RewriteRule ^index.php$ /aprilia-parts/ [L]

RewriteCond %{QUERY_STRING} ^cPath=22$
RewriteRule ^index.php$ /ducati-parts/ [L]

If You want the browser change it's URL, use [L,R=301] instead of single [L]
0
ShaneJonesAuthor Commented:
Seems to return a http 500 error on the server.
0
ravenplCommented:
Eh, lots of mistakes. Looks like it was too early in morning
Can You confirm those two typo by looking at error log?

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^cPath=21$
RewriteRule ^index.php$ /aprilia-parts/ [L]

RewriteCond %{QUERY_STRING} ^cPath=22$
RewriteRule ^index.php$ /ducati-parts/ [L]
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

ShaneJonesAuthor Commented:
hmm now returns this (scratches head)

Not Found
The requested URL /aprilia-parts/ was not found on this server.
0
ravenplCommented:
Well, do it exists? When You enter into browser the url manually, does it work? http://www.yourdomain.tld/aprilia-parts/
0
ShaneJonesAuthor Commented:
typing it into the browser does not work
0
ravenplCommented:
So first make it work. If You rewrite to something that not exists, it will return 404 (not found) error.
0

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
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.