开发者

Cutting down on mod_rewrite rules

开发者 https://www.devze.com 2023-03-12 17:48 出处:网络
I have two rewrite rules in place: one for hosting server and one for my local test server (which uses 开发者_高级运维dev-sk-... for its URLs).

I have two rewrite rules in place: one for hosting server and one for my local test server (which uses 开发者_高级运维dev-sk-... for its URLs).

'en/' is added if the site is accessed via a .co.uk domain name:

RewriteCond %{SERVER_PORT} 80 [OR]
RewriteCond %{SERVER_PORT} 443
RewriteCond %{HTTP_HOST} ^domain.co.uk$ [NC]
RewriteRule ^$ http://domain.co.uk/en/ [R=301,L]

RewriteCond %{SERVER_PORT} 80 [OR]
RewriteCond %{SERVER_PORT} 443
RewriteCond %{HTTP_HOST} ^dev-sk-domain.co.uk$ [NC]
RewriteRule ^$ http://dev-sk-domain.co.uk/en/ [R=301,L]

Can these be merged into one rule?


you should be able to write this as

RewriteCond %{SERVER_PORT} 80 [OR]
RewriteCond %{SERVER_PORT} 443
RewriteCond %{HTTP_HOST} domain.co.uk$ [NC]
RewriteRule ^$ http://%{HTTP_HOST}/en/ [R=301,L]
0

精彩评论

暂无评论...
验证码 换一张
取 消