.htaccess 需要帮助将https和www添加到htaccess文件中的重定向吗

.htaccess 需要帮助将https和www添加到htaccess文件中的重定向吗,.htaccess,redirect,url-redirection,friendly-url,.htaccess,Redirect,Url Redirection,Friendly Url,我有一组代码,可以从名为package.php的文件重定向到“pretty permalinks”结构。问题是它没有重定向到页面的https版本。我需要能够重定向到。代码如下: #Redirects hotel pages to package.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /package.php?/$1 [L] # Removes

我有一组代码,可以从名为
package.php
的文件重定向到“pretty permalinks”结构。问题是它没有重定向到页面的https版本。我需要能够重定向到。代码如下:

#Redirects hotel pages to package.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /package.php?/$1 [L]

# Removes package.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*package\.php [NC]
RewriteCond %{REQUEST_URI} !/.* [NC]
RewriteRule (.*?)package\.php/*(.*) /$1$2 [R=301,NE,L]
我有重定向代码,可以检测https是否关闭并重定向到正确的版本。但是这个代码直到上面的代码之后才被调用

#First rewrite
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
我不想把这两部分代码结合起来。这将破坏其他非包页的页面。相反,我需要第一组代码重定向到页面的https版本

任何帮助都将不胜感激

试试这些规则:

# Removes package.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*package\.php [NC]
RewriteCond %{REQUEST_URI} !/.* [NC]
RewriteRule (.*?)package\.php/*(.*) https://%{HTTP_HOST}/$1$2 [R=301,NE,L]

#Redirects hotel pages to package.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /package.php?/$1 [L]

在测试此更改之前,请确保清除浏览器缓存。

So
https://www.example.com/package-type/airport-name/hotel-name
导致404,但
http://www.example.com/package-type/airport-name/hotel-name
工作正常?我想你好像有点困惑。当我问是什么URL导致404时,你给出了
https://www.example.com/package.php?/package-类型/机场名称/酒店名称/2人
http://www.example.com/package.php?/package-类型/机场名称/酒店名称/2-peo‌​ple
导致404。请显示您的
VirtualHost
配置,以查看
https