我的代码中出现一个小 htaccess 错误
我有一个 htaccess 代码块,除了在一种特定条件下之外,它运行良好: 第一,当没有“www”时,我会添加一个“www”,这样可行。 两个当“index.html”出现时我会砍掉它。
当我末尾没有“www”和“index.html”时,就会出现问题。 我添加了 www,然后索引被砍掉并添加了整个 URL 字符串 从而重复我的 URL 并导致 404。
http://www.example.com/http://www.example.com
这是我的块有什么问题吗?
RewriteCond %{HTTP_HOST} !^www\.kisswedding\.com$ [NC]
RewriteRule ^(.*)$ http://www.kisswedding.com/$1 [L,R=301]
#RewriteCond %{REQUEST_URI} /index\.html?$ [NC]
#RewriteRule ^(.*)index\.html?$ "/$1" [NC,R=301,NE]
我确信这只是一件简单的事情,但我太累了,看不到它,所以我问你们:)
L
I have an htaccess code block that works fine well except under one particular condition:
One, I add a 'www' when there isn't one, that works.
Two I chop off 'index.html' when that appears.
The problem occurs, when I have NO 'www' AND "index.html' on the end.
I get the www added and then the index is chopped off and a whole URL string is added
thereby duplicating my URL and causing a 404.
http://www.example.com/http://www.example.com
Here is my block whats wrong?
RewriteCond %{HTTP_HOST} !^www\.kisswedding\.com$ [NC]
RewriteRule ^(.*)$ http://www.kisswedding.com/$1 [L,R=301]
#RewriteCond %{REQUEST_URI} /index\.html?$ [NC]
#RewriteRule ^(.*)index\.html?$ "/$1" [NC,R=301,NE]
I am sure its just a simple thing but I am too dang tired to see it so I ask you guys :)
L
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你需要添加
L
标志,以便 Apache 被告知停止在该规则中重写I think you need to add the
L
flag, so that Apache will be told to stop rewriting in that rule