tags:

views:

34

answers:

1

How to do the automatic redirect in .htaccess

my urlrewrite worrking fine ,

i want to redirect automatically if user enter the url as query string ,

i dont want to display query string any time,

if query string meets the urlrewrit syntax, then system should automatically redirect

this is my snippet

   RewriteRule ^index/result_id/([0-9]+)/?$ index.php?result_id=$1

but the thing is , if user try with index.php?result_id=20 then page display with query string , but i dont want somthing like this,

even if user entered the index.php?result_id=20 then system sutomatically should show the url as index/result_id/20

IS it possible wiht .htaccess

Any ideas

+2  A: 

I'm not sure if this is the only URL you want this for, but since it almost has to be customized for each URL you want to redirect anyway, hopefully it will at least be a good starting point for you.

Put this somewhere above your other rules:

RewriteCond %{THE_REQUEST} ^[A-Z]+\s/index.php?[^\s]*result_id=.* [NC]
RewriteCond %{QUERY_STRING} (result_id)=([0-9]+)
RewriteRule .* /index/%1/%2/? [R=301,L]
Tim Stone