Redirect all to index.php using htaccess

后端 未结 7 2197
情话喂你
情话喂你 2020-11-22 14:08

I\'m writing a simple PHP-based MVC-ish framework. I want this framework to be able to be installed in any directory.

My PHP script grabs the request uri and breaks

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 14:39

    just in case you were still wondering how to redirect all request either if the directory exists (for core framework folders and files) to the framework index handler, after some error/success attempts just noticed I just needed to change the RewriteCond in the .htaccess file

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    

    the above condition states "not found files" and "not found directories", ok, what if just remove "not found" (!-d) line, and ended with something like the below:

    RewriteEngine on
    RewriteBase /framework/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /framework/index.php [L,QSA]
    

    It worked for me like a charm

提交回复
热议问题