In the root folder of my project there are several other folders I am calling "apps". The path to one of these apps is something like:
/root_folder/myapp/...
There are actually a dozen apps like this. So I want my project to be using friendly URLs, and to achieve that I am using the apache module mod_rewrite.
I added the following rule to my .htaccess (that is in root_folder, just so you to know) RewriteRule ([^/]*)/(.*)?$ myDomain.com/$1/index.php?params=$2 [NC,L]
So an URL such as mydomain/myApp/param/value/param2/value would be translated to mydomain/myApp/index.php?params=value/param2/value
I performed some tests and saw it working until I added the $1 to refer to the app folder (have a look: the_path_to_my_root_folder_here/$1/index.php?params=$2)
It is generating an URL like: myDomain.com/myApp/index.php?params=index.php
Well I thought it would be a recursion issue. So it seems that Apache will try another redirection afther the first is performed, and then it will generate an URL like that
I found this thread in Stackoverflow url rewrite recursively The problem with the answer is that it`s assuming I know when to stop.
Do you know how to make this second redirection to stop?
Thanks
@EDIT
I am trying the following rule now
RewriteRule myDomain.com/([A-Za-z0-9-]+)/(.*)$/ myDomain.com/$1/index.php?params=$2 [NC,L]
But it's not working properly. It is only matching the regex, if I do not pass parameters after the app name. so when I try myDomain.com/user/ it works (not receiving parameters), and fails when I try myDomain.com/user/products/1000/, for example. Instead of rewriting/redirecting, it is trying to find a folder products inside user and etc