我创建了一个新网站。旧的使用http,新的使用https并具有不同的URL路径。
例:
OLD: website.com/index.php/powerpoint-presentation
NEW: https://website.com/powerpoint-presentation
如何以这种方式指定.htaccess中的单个URL?我想做大约10次手动301重定向。
在.htaccess文件中的旧网站上,您将使用以下内容:
Redirect 301 /index.php/powerpoint-presentation https://website.com/powerpoint-presentation
您当然可以根据需要使用多少。
单个重定向可以像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/