从头部重定向中隐藏main.html



我有一个php文件使用头重定向到main.html。我需要从url中隐藏main.html,看起来像'https://mywebsite.com/main.html '

因此,在显示main。html

内容时,它看起来像https://mywebsite.com

你可以在你的root .htaccess中使用这些规则:

RewriteEngine On
# if main.html has been sent in original request then redirect to home page
# THE_REQUEST variable represents original request received by Apache from your browser
# and it doesn't get overwritten after execution of some rewrite rules
RewriteCond %{THE_REQUEST} /main.html[s?] [NC]
RewriteRule ^main.html$ / [L,R=301,NC]
# load main.html for landing page
RewriteRule ^/?$ main.html [L]

最新更新