I want to mask the URL http://example.com/index.php?path=controller/function to http://example.com/controller/function. function isn’t required to be present.
How can I do this with an htaccess file?
The following isn’t working.
RewriteRule ^/?assets/(.*)$ assets/$1 [L] # directory for CSS, images, and JavaScript
RewriteRule ^$ /index [redirect]
RewriteRule ^([a-zA-Z]+)/?([a-zA-Z/]*)$ index.php?path=$1/$2 [L]
Currently, if I enter http://example.com/controller/function in the browser, I receive a 404 error, but entering http://example.com/index.php?path=controller/function works.
Thanks!
You may try this:
It maps internally
http://example.com/var1/var2To:
http://example.com/index.php?path=var1/var2Keeps the incoming trailing slash behavior and
var2is optional.