mod rewrite - How to make .htaccess RewriteRule without affecting index.php rules -



mod rewrite - How to make .htaccess RewriteRule without affecting index.php rules -

i'm using requests in project , want rewrite urls in such simple way: if visit mydomain.com/test request mydomain.com/get.php?txt=test on serverside.

here mine .htaccess rewriterule, works ok, problem it's affects index.php, if go main page starts: mydomain.com/get.php?txt=test request , not opening mydomain.com/index.php because of rewriterule.

options +followsymlinks rewriteengine on rewriterule (.*)$ get.php?url=$1 [l]

i don't want create sublevels in path mydomain.com/1/test, should on next level of root.

any help appreciated. give thanks you!

the mutual way add together conditions rewrite non-existing resources (files & folders):

options +followsymlinks rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule (.*) get.php?url=$1 [l]

another possible approach (which work fine your original request) ignore such rule when /index.php requested:

options +followsymlinks rewriteengine on rewritecond %{request_uri} !^/index\.php rewriterule (.*) get.php?url=$1 [l]

approach #1 highly recommended , pretty much universal. .. maybe serve resources (images/styles/javascripts/etc) via get.php (i not know application , how works) hence have provided approach.

.htaccess mod-rewrite

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -