.htaccess 如何使原始URL不可访问,但保持重写规则工作?
我有一个页面原来是.htaccess 如何使原始URL不可访问,但保持重写规则工作?,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我有一个页面原来是 https://www.domain.com/page.php 我将它重定向到 https://www.domain.com/page 与 有没有办法让它只能通过page访问,但当有人键入page.php时,他们会被重定向到404.html,例如?为什么没有 重写规则^page.php$error\u 404.php ?是,可以使用其他规则执行: # block direct request for /page.php RewriteCond %{THE_REQUEST}
https://www.domain.com/page.php
我将它重定向到
https://www.domain.com/page
与
有没有办法让它只能通过page
访问,但当有人键入page.php
时,他们会被重定向到404.html,例如?为什么没有
重写规则^page.php$error\u 404.php
?是,可以使用其他规则执行:
# block direct request for /page.php
RewriteCond %{THE_REQUEST} /page\.php [NC]
RewriteRule ^ - [F,L]
RewriteRule ^page/?$ page.php [L,NC]
# block direct request for /page.php
RewriteCond %{THE_REQUEST} /page\.php [NC]
RewriteRule ^ - [F,L]
RewriteRule ^page/?$ page.php [L,NC]