首页 > 解决方案 > 关闭对非链接在 htaccess 中重写的页面的访问

问题描述

我编写的 htaccess 代码使我的 url seo 友好

RewriteEngine on 
RewriteBase /
RewriteRule ^p/([^/]+)/([^/]+)$ page.php?id=$1&title=$2 [QSA]

真正的页面访问格式是page.php?id={id}&title={title}.

并使用 htaccessp/{id}/{title}

所以我想停止page.php使用真实格式的访问。那可能吗 ?

标签: php.htaccess

解决方案


尝试使用低于当前重写规则的以下规则,

RewriteCond %{REQUEST_FILENAME} ^page.php
RewriteCond %{QUERY_STRING} ^id=$1&title=$2
RewriteRule ^ - [F]

推荐阅读