I’m using GET requests in my project and I want to rewrite URLs in such a simple way: if I visit mydomain.com/test it will request mydomain.com/get.php?txt=test on my serverside.
Here is mine .htaccess RewriteRule, it works OK, but problem that it’s also affects my index.php, so if I go to main page it starts: mydomain.com/get.php?txt=test request and not opening mydomain.com/index.php because of my RewriteRule.
Options +FollowSymLinks
RewriteEngine On
RewriteRule (.*)$ get.php?url=$1 [L]
I don’t want make any extra sublevels in the path like mydomain.com/1/test, it should be on the next level of root.
Any help appreciated. Thank you!
The most common way is to add conditions to only rewrite non-existing resources (files & folders):
Another possible approach (which will work fine for your original request) is to ignore such rule when
/index.phpis requested:Approach #1 is highly recommended and is pretty much universal. But .. maybe you serve all resources (images/styles/javascripts/etc) via
get.phpas well (I do not know what your application does and how it works) hence I have provided another approach.