I’m building my own MVC application with php. index.php will be the front controller.
In index.php i will take the parameters with $_SERVER[‘QUERY_STRING’], so i need my
.htaccess file to redirect /attr1/attr2/attr3 to index.php?attr1/attr2/attr3.
($_SERVER[‘PHP_SELF’] doesn’t work properly)
if my htaccess file (apache server) is
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ index.php?$1
</IfModule>
query_string outputs index.php
but if i access url via localhost/something/attr1/attr2/attr3 and .htaccess is
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(something)\/(.*)$ index.php?$2
</IfModule>
query_string is printing attr1/attr2/attr3
WTF??
I do like this:
and then the url will be in the $_GET array (the 4th and 5th lines ensure the rule applies when there is no actual file at that path)