

<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SEO_网站优化_网络推广公司 &#187; 不允许用于访问此页</title>
	<atom:link href="http://seo.heiku8.com/tag/ڷʴҳ/feed" rel="self" type="application/rss+xml" />
	<link>http://seo.heiku8.com</link>
	<description>【黑酷哥】</description>
	<lastBuildDate>Sat, 09 Nov 2024 19:09:08 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.18</generator>
	<item>
		<title>php405不允许用于访问此页的 HTTP 谓词</title>
		<link>http://seo.heiku8.com/4727.html</link>
		<comments>http://seo.heiku8.com/4727.html#comments</comments>
		<pubDate>Fri, 31 Dec 2021 03:09:45 +0000</pubDate>
		<dc:creator><![CDATA[黑酷SEO]]></dc:creator>
				<category><![CDATA[网站优化]]></category>
		<category><![CDATA[HTTP 谓词]]></category>
		<category><![CDATA[php405]]></category>
		<category><![CDATA[不允许用于访问此页]]></category>

		<guid isPermaLink="false">http://seo.heiku8.com/?p=4727</guid>
		<description><![CDATA[405 &#8211; 不允许用于访问此页的 HTTP 谓词。 您要查找的页面无法显示，因为尝试访问时使用了无效方法(HTTP 谓词)。 这篇文章主要介绍了php禁止直接从浏览器输入地址访问的方法，实例总结了判断来源URL与定义常量两种方法来实现这一功能，是非常具有实用价值的技巧 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>405 &#8211; <a href="http://seo.heiku8.com/tag/%e4%b8%8d%e5%85%81%e8%ae%b8%e7%94%a8%e4%ba%8e%e8%ae%bf%e9%97%ae%e6%ad%a4%e9%a1%b5" title="【查看含有[不允许用于访问此页]标签的文章】" target="_blank">不允许用于访问此页</a>的 <a href="http://seo.heiku8.com/tag/http-%e8%b0%93%e8%af%8d" title="【查看含有[HTTP 谓词]标签的文章】" target="_blank">HTTP 谓词</a>。</p>
<p>您要查找的页面无法显示，因为尝试访问时使用了无效方法(<a href="http://seo.heiku8.com/tag/http-%e8%b0%93%e8%af%8d" title="【查看含有[HTTP 谓词]标签的文章】" target="_blank">HTTP 谓词</a>)。</p>
<p>这篇文章主要介绍了php禁止直接从浏览器输入地址访问的方法，实例总结了判断来源URL与定义常量两种方法来实现这一功能，是非常具有实用价值的技巧，需要的朋友可以参考下，一般来说对于有些重要的文件我们并不希望用户可以直接输入地址进行访问，对此我们需要进行一些设置。</p>
<p>比如说http://www.heiku8.com/xxx.php 这个文件我不想让别人直接从浏览器输入地址访问。</p>
<p>本文讲述3种方法来实现，在xxx.php文件头部写上以下代码就可以。</p>
<p>1、判断是否直接在浏览器输入的url，如果是则跳转到指定页面$fromurl=&#8221;/404.html&#8221;; //指定跳转路径</p>
<p>if( $_SERVER[&#8216;HTTP_REFERER&#8217;] == &#8220;&#8221; )//判断规则</p>
<p>{</p>
<p>header(&#8220;Location:&#8221;.$fromurl); //执行判断结果</p>
<p>exit;</p>
<p>}</p>
<p>2、判断是否直接在浏览器输入的url，如果是则返回404状态码if( $_SERVER[&#8216;HTTP_REFERER&#8217;] == &#8220;&#8221; ) //判断规则</p>
<p>{</p>
<p>header(&#8220;HTTP/1.1 404 Not Found&#8221;); //返回404状态码</p>
<p>header(&#8220;Status: 404 Not Found&#8221;); //返回404状态码</p>
<p>exit;</p>
<p>}</p>
<p>3、验证传递参数是否为空$code = isset($_POST[&#8216;code&#8217;])? $_POST[&#8216;code&#8217;] : &#8221;; //判断传值 $code 字段是否为空</p>
<p>if(empty($shouji)){ //如果为空，则提示</p>
<p>exit(&#8216;此文件不可访问&#8217;);</p>
<p>};</p>
]]></content:encoded>
			<wfw:commentRss>http://seo.heiku8.com/4727.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
