简体   繁体   中英

How to define the application boot file in htaccess

OK, the question might look a bit over discussed but unfortunately I couldn't find a good answer for myself.

How to define a boot file for my web application in .htaccess that will run every time a request to my website is made? ZF uses application/index.php to define all global variables like: APPLICATION_ENV , include_path() etc. WordPress does this to load the necessary theme.

Here's what I have in my .htaccess file:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]

But I'm not sure how good this is: I think there may be cases accounted for improperly.

Say you want everything to be routed through /boot.php , then you'd do one of the following:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/boot\.php
RewriteRule ^(.*)$ /boot.php [L]

or

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /boot.php [L]

You can pass additional parameters to the boot.php either through the _SERVER['REQUEST_URI'] variable or through the query string:

RewriteRule ^(.*)$ /boot.php?path=$1 [L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM