多个htaccess重写条件/角路由html5模式 [英] multiple htaccess rewrite Conditions / angular routes html5 mode

查看:51
本文介绍了多个htaccess重写条件/角路由html5模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在html5模式下有一个带有路线的角度项目.我设置了htaccess文件,可以手动插入域或刷新页面.

i have a angular project with routes in html5 mode. I set up a htaccess file, that is possible to insert a domain manually or refresh the page.

在此,基于此的htaccess代码可以正常工作 在手动刷新时仍显示未找到" angular.js路线

here the htaccess code with works fine, based on this Still getting 'Not Found' when manually refreshing with angular.js route

    RewriteEngine On

 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]

 RewriteRule ^ myFolder/myFile.php [L]

但是现在我还想将URL重定向到https宽度www,例如:

but now i want also to redirect the url to https width www, for example:

http://example.com 应该成为有我用过的

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

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

但是当我尝试结合使用这些脚本时,我总是会出错!

But when i try to combine this scripts i always get error!

谢谢!

推荐答案

我不确定您是如何尝试组合代码的,但是您应该可以这样做.将example.com替换为您的域.

I'm not sure how you're trying to combine the code, but you should be able to do it this way. Replace example.com with your domain.

 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTPS} !^on [OR]
 RewriteCond %{HTTP_HOST} ^example\.com [NC]
 RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]

 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]

 RewriteRule ^ myFolder/myFile.php [L]

在尝试新规则之前,请清除浏览器缓存.

Clear your browser cache before trying the new rules.

这篇关于多个htaccess重写条件/角路由html5模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆