简体   繁体   English

.htaccess RewriteRule问题

[英].htaccess RewriteRule issue

I have a domain at OVH that links to my EC2 instance like this: www.mysite.com --> 12.34.56.78/folder/ So everytime I type "www.mysite.com" in my address bar I end up on my website but the URL has been replaced to "12.34.56.78/folder/". 我在OVH拥有一个链接到我的EC2实例的域名,如下所示:www.mysite.com-> 12.34.56.78/folder/因此,每次我在地址栏中键入“ www.mysite.com”时,我都会进入我的网站但网址已替换为“ 12.34.56.78/folder/”。

I'm currently trying to tweak a .htaccess file at the root of my server but it doesn't seem to work... Here is the content of the file: 我目前正在尝试在服务器的根目录处调整.htaccess文件,但似乎无法正常工作...这是文件的内容:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.mysite.com$
RewriteRule ^(.*)$ http://www.mysite.com/ [L]

Maybe I'm not looking at the right solution... Anyway if you can help me, I'll be grateful! 也许我不是在寻找正确的解决方案...无论如何,如果您能帮助我,我将不胜感激! Cheers, 干杯,

You are missing a couple of things that I added below 您缺少我在下面添加的几项内容

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ 
#$1 will include the original URI in the redirect, 301 for permanent
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM