【发布时间】:2020-08-11 20:12:13
【问题描述】:
当前的 URL 是 https://example.com/page/horeca,这是完美的。
但如果我输入“https://www.example.com/page/horeca”之类的“www”,页面将重定向到https://example.com/page.php?s=horeca。
输入“https://www.example.com/page/horeca”后,我希望 URL 为“https://example.com/page/horeca”。即隐藏“www”并隐藏“.php”。
【问题讨论】:
-
这需要一个 .htaccess 重定向。你的 RewriteCond 技能有多好?
-
RewriteEngine On RewriteBase / RewriteRule page/(.*) page.php?s=$1 [NC,L] RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https:// %{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ https://%1%{REQUEST_URI} [R=301 ,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L]
-
我也尝试过但不工作 重定向 301 ^/page.php?s=horeca example.com/page/horeca