通过.htaccess将单个HTTP URL重定向到HTTPS

问题描述 投票:1回答:2

我创建了一个新网站。旧的使用http,新的使用https并具有不同的URL路径。

例:

OLD: website.com/index.php/powerpoint-presentation

NEW: https://website.com/powerpoint-presentation

如何以这种方式指定.htaccess中的单个URL?我想做大约10次手动301重定向。

.htaccess http redirect https url-redirection
2个回答
1
投票

在.htaccess文件中的旧网站上,您将使用以下内容:

Redirect 301 /index.php/powerpoint-presentation https://website.com/powerpoint-presentation

您当然可以根据需要使用多少。


0
投票

单个重定向可以像Dave提到的那样完成:

Redirect 301 /index.php/powerpoint-presentation https://website.com/powerpoint-presentation

但是,如果您的所有旧URL都以相同的方式构建,并且您只想删除/index.php/,则可以执行以下操作:

RewriteEngine On
RewriteRule ^index\.php/(.*)$ https://website.com/$1 [R=301,L]

这将使用旧的/index.php/结构将任何URL重定向到https://网站上的相同URL,而不使用/index.php/

© www.soinside.com 2019 - 2024. All rights reserved.