![](/img/trans.png)
[英]Apache2 PHP - How do I use .htaccess to rewrite direct download links
[英]How to rewrite URL with `.htaccess`, which disallows direct links?
我用htdocs
文件夹中的一些文件创建了我的网站,例如: .htaccess
, detail.php
...过去,我为网站使用了旧的URL结构: detail.php?id=12
。 然后,通过使用以下简单的.htaccess
,我使用了一个新的: product/12
:
RewriteEngine On
RewriteRule "^product/([0-9]+)/?$" "/detail.php?$1"
现在,我不希望任何用户都可以使用旧的URL结构访问我的网站。 如果您不介意,您可以告诉我:如何使用.htaccess
重写URL,以禁止直接链接?
在我的演讲中,
disallows direct links
装置404
用于直接链接。
要禁止您的旧链接,可以使用以下规则:
RewriteEngine on
RewriteCond %{THE_REQUEST} /product\.php\?id=.*$
RewriteRule ^ - [R=404,L]
这会将您的旧链接重定向到您网站的404错误页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.