Link to home
Start Free TrialLog in
Avatar of ShaneJones
ShaneJonesFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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
Avatar of ravenpl
ravenpl
Flag of Poland image

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]
Avatar of ShaneJones

ASKER

Seems to return a http 500 error on the server.
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]
hmm now returns this (scratches head)

Not Found
The requested URL /aprilia-parts/ was not found on this server.
Well, do it exists? When You enter into browser the url manually, does it work? http://www.yourdomain.tld/aprilia-parts/
typing it into the browser does not work
ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial