I've been trying to attempt this, but I am unable to yield any results. I'm trying to rewrite a variable into a "directory" in the url to multiple files.. I better explain this is what I mean.
Without the rewrite:
/index.php?var=test
/admin/panel.php?var=test
/faq.php?var=test
/directory/test.php?var=test
With the rewrite:
/test/index.php
/test/admin/panel.php
/test/faq.php
/test/directory/test.php
I'd like to be able to pass other variables to the files as well.. example:
/test/index.php?user=1&session=1233445
I realize that I could do a rewrite rule for every physical file and directory.. but I want it to be dynamic so if I add files to my site I don't have to keep editing the .htaccess file. Any help would be appreciated. Thanks!
Try:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/(.*?/?)(index|panel|faq|test)\.php$ /$2$3.php?var=$1 [L,QSA]