0

I am getting value using GET request from the following link:

http://example.com/index.php?param=value

I am using jquery to grab the URL and then separate param and value. Now i want the url in following format:

http://example.com/param/value

And in Jquery I want to capture the param and value. Can this be achieved with help of htaccess ?

Pushpa Raj
  • 79
  • 1
  • 12
  • .htaccess can only help you with the server-side part; but if you want to get those parameters from the URL on the client-side using JavaScript, then you will need to modify your logic that performs that task accordingly. – CBroe Jul 30 '18 at 14:17
  • The answer below by @Nisarg allows you to open `http://example.com/param/value` in your browser while secretly calling `http://example.com/index.php?param=value` instead. In jQuery (in all JavaScript actually), you can get the `/param/value` using `window.location.pathname` using [this](https://stackoverflow.com/a/31518080/1807809) method. – Damodar Dahal Jul 30 '18 at 14:30

1 Answers1

0

Try this:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /recent/

RewriteRule ^([^/]+)/([0-9]+)/?$ index.php?$1=$2 [L,QSA]
Nisarg
  • 1,631
  • 6
  • 19
  • 31