如何将 HTTP_REFERER 从 htaccess 转发到页面?

当有人点击我的网站根文件夹 (www.myDomain.com) 并且 Index.php 页面获取它时,我如何将 HTTP_REFERER 转发到 Index.php 页面以便我可以记录它?


我有这个,但没有快乐。


RewriteEngine On

RewriteCond %{HTTP_REFERER} !^mydomain.com [NC]

RewriteRule ^/?index.php?%{HTTP_REFERER}$ mydomain.com/ [L,R]

谢谢


德玛西亚99
浏览 52回答 1
1回答

呼唤远方

确保 apache mod_rewrite 已启用。然后重定向:<IfModule mod_rewrite.c>&nbsp; &nbsp; # Make sure url's can be rewritten.&nbsp; &nbsp; RewriteEngine on&nbsp; &nbsp; # Redirect requests that are not files or directories to index.php.&nbsp; &nbsp; RewriteCond %{REQUEST_FILENAME} !-f&nbsp; &nbsp; RewriteCond %{REQUEST_FILENAME} !-d&nbsp; &nbsp; RewriteRule ^ index.php [L]</IfModule>大多数 CMS 都是这样做的。这确实意味着如果他们将直接路径写入文件,他们将看到该文件。因此,您需要在此之前添加以下内容:# Prevent direct access to these file types.<FilesMatch "\.(sql|md|sh|scss|rb|conf|rc|tpl(\.php)?|lib(\.php)?|wig(\.php)?|pg(\.php)?|reg(\.php)?|db(\.php)?)$">&nbsp; Require all denied</FilesMatch>这意味着他们无法访问上面列出的文件扩展名。您可以用 just 替换最后几个,rc|php但我允许访问 .php 文件而不是 .lib,这样我就可以执行受浏览器身份验证保护的脚本来进行调试和银弹数据库修复。您的 apache 配置中还必须有类似的内容,以允许在您的站点目录中读取 .htaccess。<Directory "C:/Sites">&nbsp; &nbsp; AllowOverride All</Directory>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5