美文网首页
vue router 使用 History 模式后端 apach

vue router 使用 History 模式后端 apach

作者: 莫伊剑客 | 来源:发表于2020-03-11 22:15 被阅读0次
1.在上传的web项目根目录下创建 .htaccess 文件(前面有个点),在其中添加如下配置
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

2.设置apache支持mod_rewrite

找到apache安装目录 etc/apache/conf/ 下的 httpd.conf 文件
通过Ctrl+F查找到 LoadModule rewrite_module,将前面的”#”号删除即可。

3.设置apache支持override

在 httpd.conf 文件里
通过Ctrl+F找到对应的DocumentRoot 里的“AllowOverride None”,修改为"AllowOverride All"

4.重启apache

sudo apachectl restart

相关文章

网友评论

      本文标题:vue router 使用 History 模式后端 apach

      本文链接:https://www.haomeiwen.com/subject/fpskjhtx.html