i have been working on a framework that i am creating in php and the essential part for it to work is to send all the url queries to index.php in the root folder. I managed to do it in the folloowing code at my .htaccess file
# Turn rewriting on
Options +FollowSymLinks
RewriteEngine On
# Redirect requests to index.php
#RewriteRule ^(phpmyadmin)($|/) - [L]
RewriteRule ^(html)($|/) - [L]
RewriteCond %{REQUEST_URI} !=/index.php
RewriteCond %{REQUEST_URI} !.*\.png$ [NC]
RewriteCond %{REQUEST_URI} !.*\.jpg$ [NC]
RewriteCond %{REQUEST_URI} !.*\.css$ [NC]
RewriteCond %{REQUEST_URI} !.*\.gif$ [NC]
RewriteCond %{REQUEST_URI} !.*\.js$ [NC]
RewriteRule .* /index.php
The problem occurs when i move the site to a different folder for example
www.mydomain.com/subdir/{where the index.php is, along with htaccess}
and it stops working here. The same happens if i move the framework application to a sub-domain as well.
so I am trying to modify .htaccess to rewrite to index.php properly where the .htaccess file is at regardless if it is in a sub-directory or sub-domain. How can i get the .htaccess to know that application is in a sub-directory and rewrite to it properly so change of location does not break .htaccess pointing to the right file?
www.domain.com/{.htaccess+index.php + framework} => works properly
www.subdom.domain.com/{.htaccess+index.php + framework} => does not work
www.domain.com/subdir/{.htaccess+index.php + framework} => does not work //send to www.domain.com/index.php
localhost/projectname/{.htaccess+index.php + framework} =>does not work
As you can see it needs to send the requests to index.php where htaccess is also located at.
/index.phpto justindex.php? Of course now you'd need to have an index.php in EVERY directory.RewriteBasenot an option for you? With it you could easily fix the issue by changing 2 entries on your.htaccesswhen you need to move if you need to move.RewriteBase /folder_it_is_now/and your/index.phpintoindex.phpat theRewriteRule.RewriteBaseand theindex.phpchecks. If that is usable to your situation I will turn that into a answer, but if you don't want to change any files or anything I will just leave it as a comment.