我想要apache:
我尝试了不同的口味,但不能得到它的工作。 当用户访问网站时,他们被redirect到https://,但是我无法获得/ {numeric}redirect到添加/查看/。 数字规则工作正常,直到我把httpsredirect。
我已经尝试了RewriteCond%{HTTPS} = on,但是这会导致500个错误。
RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://domain.example.org/$1 [R,L] RewriteRule ^(\d+)$ https://domain.example.org/view/$1 [R=301,L]
将第一个RewriteCondreplace为:
RewriteCond %{SERVER_PORT} !^443$
这不适合你吗?
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
试试这个来testing:
http://htaccess.madewithlove.be/
好吧,听起来你真的想要这样的东西:
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{REQUEST_URI} /1234 RewriteRule (.*) https://%{HTTP_HOST}/view%{REQUEST_URI} [L]
这将是一个closures袖口的答案,但是,我相信重写规则以先到先得的方式匹配。 由于path结构发生变化,我敢打赌你的http://domain.example.org/1234用户会被redirect到https的等效path,但不会改变path。 尝试切换规则的顺序,您将接近完整的解决scheme。
如果这不起作用,请让我知道,我将启动一个Apache实例,我们将看到我们可以一起工作。
谢谢你的帮助。
我终于有了工作。 我使用了以下内容:
RewriteCond %{HTTPS} off RewriteRule ^/?(.*) https://domain.example.org/$1 [R,L] RewriteRule ^([0-9]+)/?$ https://%{HTTP_HOST}/view/$1 [NC,L]
因此,任何数字请求都会添加/视图,任何尝试访问使用http://的网站都会被转发到https://。 似乎运作良好。