.htaccess 如何使用url名称更改将页面从http重定向到htpps
我有以下问题 我需要两样东西:.htaccess 如何使用url名称更改将页面从http重定向到htpps,.htaccess,redirect,mod-rewrite,url-rewriting,friendly-url,.htaccess,Redirect,Mod Rewrite,Url Rewriting,Friendly Url,我有以下问题 我需要两样东西: 从不安全HTTP重定向到安全HTTPS,然后 从https://example.com/index.html至https://example.com/work-for-us 我知道我可以通过以下方式获得的第一个: RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 第二个是使用 RewriteEngine on
https://example.com/index.html
至https://example.com/work-for-us
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
第二个是使用
RewriteEngine on
RewriteRule work-for-us index.html
但有没有可能把这两者联系起来呢
所以我有HTTP->HTTPS和/index.html->/为我们工作
我对.htaccess文件没有太多的了解,我在网上读了一些东西,但没有找到任何能回答我问题的东西
因此,将所有内容放在一起,我想更改以下URL:
http://example.com/index.html
到此https://example.com/work-for-us
提前谢谢。基于您展示的样品,请尝试以下内容。 请确保在测试URL之前清除浏览器缓存
RewriteEngine on
##First rule for applying https to URLs.
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
##Second rule for serving homepage(only dns link) with index.html file.
RewriteRule ^/?$ work-for-us [R=301]
RewriteRule ^/?$ index.html [L]
##Third rule for serving non-existing directories/files with index.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [L]
感谢分享您的努力,这意味着您正在点击链接
http://example.com/index.html
在浏览器中?并希望它在浏览器中更改为https://example.com/work-for-us
?请确认一下。我从谷歌进入网站,它会点击https://example.com(因为我使用了从HTTP到https的重写规则)。服务器上加载的文件是index.html。所以出现在URL栏中的是https://example.com。但回答你的问题——如果有人写了你写的东西,那么是的,我希望他们被重定向到你写的@RavinderSingh13