0

I have a url like this:

localhost/site/index.php?option=com_cust&tool=edit

and I would like to replace index.php?option=com_cust&tool=edit to edit. Is this possible? The attempts I have made do not work, e.g. :

RewriteEngine On
RewriteRule ^index.php?option=com_cust&tool=edit localhost/site/edit [L,QSA,R=301]
A Smith
  • 237
  • 5
  • 16
  • Possible duplicate of: [htaccess-rewrite-for-query-string](http://stackoverflow.com/questions/1231067/htaccess-rewrite-for-query-string) – Zuul May 10 '12 at 22:03
  • Possible duplicate of: [how-to-change-url-query-string-with-php-htaccess](http://stackoverflow.com/questions/9528728/how-to-change-url-query-string-with-php-htaccess) – Zuul May 10 '12 at 22:04
  • 1
    You can read about htaccess tricks and tips [here](http://corz.org/serv/tricks/htaccess2.php?page=1) and find some very useful information! – Zuul May 10 '12 at 22:06

1 Answers1

1
RewriteRule ^site/edit site/index.php?option=com_cust&tool=edit [L]

You had it backwards - what the rewrite module does is it takes in what the user typed in (in this case, 'edit') and it transforms it into something your server can understand (loading index.php and passing a bunch of variables to it).

Also, you definitely don't want an external redirect, much less a 301 redirect. 'L' should be the only flag you need here.

Ansari
  • 8,168
  • 2
  • 23
  • 34
  • Hi, thanks for your help, and explaining. I applied the rule but the url still doesn't change? I have Options +FollowSymlinks and RewriteEngine on set so I don't know why it's not working? – A Smith May 11 '12 at 11:48
  • No problem - do you have AllowOverrides All also set? Try inserting some random characters in your .htaccess file to see if it throws a 500 error. – Ansari May 11 '12 at 15:40
  • Yes I have that set in my httpd, and random characters throws a 500 error on the site too. – A Smith May 11 '12 at 18:04
  • OK that's helpful. Now, what exactly happens when you go to the URL localhost/edit? Does it say URL /edit not found? – Ansari May 11 '12 at 19:51
  • 1
    I'm so sorry - I didn't notice the `site` part of the URL. I updated my answer, can you check now? – Ansari May 11 '12 at 21:35
  • 1
    Make it `RewriteRule ^(site)/(edit)/?$ $1/index.php?option=com_cust&tool=$2 [L,NC,QSA]` – anubhava May 11 '12 at 21:41