1

我正在尝试重新写入一个名为 /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 是一个测试网址顺便说一句)

我还尝试将子文件夹中的 .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(然后获取变量等)

IE

 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更复杂。非常感谢任何指针/帮助等

4

1 回答 1

1

您的 RewriteRule 似乎表明您正在尝试采用非安全 url 并通过 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]
于 2012-10-01T21:44:00.797 回答