【问题标题】:Need to redirect 301 a URL in .htaccess file but it adds extra http//?需要在 .htaccess 文件中重定向 301 一个 URL,但它添加了额外的 http//?
【发布时间】:2021-07-22 18:05:55
【问题描述】:

我正在尝试将 /abc.html 重定向到 /abc.php,但是当我这样做时,它给出了一个 额外的 http// 并且页面无法像 那样工作>http//www.example.de/abc.php不知道这个HTTP是从哪里来的。

注意:网站没有ssl所以域名是http://example.de

我的 .htaccess 文件

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://example.de/$1 [R=301,L]
RedirectPermanent /tour.html /tour.php

【问题讨论】:

    标签: apache .htaccess mod-rewrite url-rewriting friendly-url


    【解决方案1】:

    使用您显示的示例/尝试,您能否尝试以下操作。请确保在测试您的 URL 之前清除您的浏览器缓存。

    RewriteEngine ON
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [NE,R=301,L]
    
    ##To serve home page link.
    RewriteRule ^/?$ index.php [L]
    
    RewriteCond %{REQUEST_URI} !^/?$
    RewriteRule ^([^.]*)\.html/?$ $1.php [NC,L]
    

    【讨论】:

    • @Christinaleonel,您能否提及您遇到错误的网址示例?
    • Internal Server Error 我的网站名称是 die-malireise.de 它不是安全的 https,它现在是 http
    • @Christinaleonel,哦,好的。您能否使用我更新的规则一次,如果这对您有帮助,请告诉我?请确保在测试您的 URL 之前清除浏览器缓存。
    • 谢谢你的完美
    • @Christinaleonel,欢迎您的欢呼和快乐的学习。继续发布好的问题和答案?
    猜你喜欢
    • 2015-06-24
    • 1970-01-01
    • 2016-01-11
    • 1970-01-01
    • 2011-07-25
    • 1970-01-01
    • 1970-01-01
    • 2012-04-08
    • 2012-08-18
    相关资源
    最近更新 更多