这是一个
有效的 redict 命令,用于将 URL 中将 www 前缀写入同一 URL 的用户重新定义,而无需 www。
<VirtualHost _default_:443>
ServerName example.org
ServerAlias www.example.irg
RedirectMatch 301 https://www.example.org https://example.org
谢谢
不,它无效,RedirectMatch
看不到您的域,正则表达式仅适用于您的 URL 路径。
https://domain.com
/my-URL-path
您可以使用这些规则:
RewriteEngine On
RewriteCond %{HTTP_HOST} !=""
RewriteCond %{HTTP_HOST} ^www. [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
对https://www.example.org/home
的查询将重定向到https://example.org/home