我正在尝试重新编写一个名为/ checkout的特定子文件夹,这个子文件夹附有为https附加的SSL证书
所以我在我的网站的根文件夹中有这个 -
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
# in http: force secure.html to https
RewriteCond %{server_port} !=443
RewriteCond $1 ^([^/]+)$ [NC]
# this kinda works below but is resolving to index2.php and is showing in the url so not really working yet
RewriteRule checkout/([^/]+)\.html$ https://mysite.com/checkout/index2.php [L]
除了显示类似
之外的其他内容https://mysite.com/checkout/index.html
显示
https://mysite.com/checkout/index2.php
(index2.php是测试网址btw)
我也尝试将子文件夹中的.htaccess修改为类似
的内容Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{server_port} !=443
RewriteCond $1 ^([^/]+)$ [NC]
RewriteRule ^([^/\.]+)/?$ https://mysite.com/checkout/index2.php [L]
我只想处理
https://mysite.com/checkout/index.html
或https://mysite.com/checkout/about-us.html
就像我在根中一样
https://mysite.com/index.html
=> https://mysite.com/index.php
(然后获取变量等)
即
RewriteRule ^/?(catalogue-page)/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+) index2.php?friendly_url=$1&catalogue_id=$2&view=catalogue&categoryid=$3&subcategoryid=$4&subjectid=$5&item=$6
我认为https更复杂。 任何指针/帮助等非常赞赏
答案 0 :(得分:1)
您的RewriteRule似乎表明您正在尝试使用非安全网址并通过https显示不同的网页,这本身是不可能的。说过你的描述听起来并不像是总体目标。
如果您希望强制安全的非安全URL,这很好,也可以将index.html的请求发送到服务器index.php。然而,不可能一下子做到这一切。
# first force urls to be secure.
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^checkout/([^/\.]+)/?$ https://mysite.com/%{REQUEST_URI} [R=301,L]
# now rewrite them, so that the requests all get served through the front controller
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^checkout/([^/\.]+)/?$ /checkout/index2.php [L]