How to trigger 'Rewrite Rule' by a URL with get parameters sent by form

I need help with using RewriteCond properly in my .htaccess. I have a simple php file which accepts 2 get parameters and returns a JSON object. Well, I wrote a simple Rewrite Rule to make my url pretty and understandable. Although after adding a form, obviously the Rewrite Rule won't get triggered because it will send a standard 'raw' URL.

My normal URL looks like this:

www.example.com/?ost=1&song=2

After my Rewrite Rule:

www.example.com/ost/1/song/2

But the form sends the url like this: www.ost.com/?ost=1&song=2

After searching a bit, I found out that RewriteCond could help but I am not familiar with it.

Edit: I have been asked for my Rule, so here it is: RewriteRule ^(ost)/([^/.]+)/?(song)?/?([^/.])?$ index.php?$1=$2&$3=$4

I forgot to mention that the song parameter is optional but this doesn't matter.



from Recent Questions - Stack Overflow https://ift.tt/3GW2aJM
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)