将所有流量定向到根索引页



是否可以将代码添加到站点的根htaccess文件,将所有流量定向到站点的主索引页面? 例如,如果有人转到以下任何 URL,则应将其重定向到 example.com:

  • subdomain.example.com
  • example.com/directory

您可以在站点根目录.htaccess中使用这些规则example.com

DirectoryIndex index.html
RewriteEngine On
RewriteCond %{REQUEST_URI} !(?:jpe?g|gif|png|ico|tiff|css|js)$ [NC]
RewriteRule !^index.html$ /index.html [L,NC,R]

最新更新