首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更改根目录

问更改根目录
EN

Stack Overflow用户
提问于 2021-06-19 17:31:08
回答 1查看 307关注 0票数 0

我希望将根目录从www.example.com/index.html (基本目录)更改为子目录www.example.com/dist/index.html,并使用.htaccess规则充当www.example.com。

EN

回答 1

Stack Overflow用户

发布于 2021-06-20 13:59:15

要检查的示例.htaccess文件:

代码语言:javascript
复制
<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>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68049280

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档