我已经在PHP中创建了一个保存到数据库中的命中,并且脚本当前只在您导航到脚本所在的页面时运行,我想要这样做,所以每当我的页面加载它时运行脚本.我相信我必须在.htaccess文件中执行此操作,我不确定如何操作.
这是我当前的.htaccess文件
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{HTTP_HOST} !^www\.giantnodes\.com [NC]
RewriteRule ^(.*)$ http://www.giantnodes.com/$1 [R=301,L]
ErrorDocument 400 /400.html
ErrorDocument 401 /401.html
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
Run Code Online (Sandbox Code Playgroud)
auto_prepend_file每次运行请求的脚本之前,您都可以使用它来运行脚本.
您可以在php.ini文件或.htaccess文件中进行设置.
对于.htaccess您可以添加这样的:
php_value auto_prepend_file "/path/to/your/file.php"
Run Code Online (Sandbox Code Playgroud)