Php 如何在htaccess中合并订单

Php 如何在htaccess中合并订单,php,.htaccess,Php,.htaccess,我有几个具体的网页在我的网站,我需要强制SSL。 我的代码运行良好,但它使.htaccess文件中的代码长度过大 有没有办法将所有这些页面合并成一个较小的代码 这是我现在拥有的代码: RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} clientarea.php RewriteRule ^(.*)$ https://example.com/$1 [R,L] RewriteEngine On

我有几个具体的网页在我的网站,我需要强制SSL。 我的代码运行良好,但它使.htaccess文件中的代码长度过大

有没有办法将所有这些页面合并成一个较小的代码

这是我现在拥有的代码:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} clientarea.php
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} submitticket.php
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} contact.php
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} cart.php
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
所以我有clientrea.php、submitticket.php、contact.php和cart.php文件页

如何将它们组合成一个代码,而不是4个相同的代码


谢谢

要强制特定页面使用https,您可以使用以下方法:

RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(page1|page2|page3)/?$ https://example.com/$1 [R,L]
您可以在规则的模式中包含多个页面,只需使用管道|字符将它们分开即可