更改ROOT文件夹目录

时间:2021-06-19 17:31:08

标签: apache .htaccess web server routes

我想将根文件夹目录从 www.example.com/index.html(基本目录)更改为子目录 www.example.com/dist/index.html 并充当 { {3}} 使用 .htaccess 规则

1 个答案:

答案 0 :(得分:1)

要检查的示例 .htaccess 文件:

<IfModule mod_rewrite.c>
  RewriteEngine On

  # Your new base directory for files - example index.html
  RewriteBase /dist/

  # Place for your own rules - example with non-www to www, index.html to domain, http to https

  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteCond %{HTTP_HOST} ![0-9]$ [NC]
  RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]

  RewriteCond %{REQUEST_URI} ^\/index.(html|htm)$
  RewriteCond %{QUERY_STRING} ^$
  RewriteRule ^(.*)$ https://%{HTTP_HOST}/ [L,R=301]

  RewriteCond %{HTTPS} !=on
  RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]

</IfModule>
相关问题