Apache mod_rewrite更改域扩展

时间:2019-02-14 21:19:55

标签: apache mod-rewrite

我想使用4个条件的mod_rewrite。

http to https
http://example.com to https://example.com

www. to non-www.
https://www.example.com to https://example.com
https://www.subdomain.example.com to https://subdomain.example.com

non-plural ending to plural ending domain
https://www.example.com to https://examples.com

.com (or that is not .co) domain extension to .co
https://www.example.com to https://examples.co

到目前为止,我有以下代码:

ServerName examples.co
ServerAlias *.examples.co examples.com *.examples.com example.co *.example.co example.com *.example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !examples\.co$
RewriteCond %{HTTP_HOST} ^([^.]+\.)?examples\.
RewriteRule ^ https://%1examples.co%{REQUEST_URI} 

我很难找到一个示例来创建将 example 更改为 examples 并将 .com (或其他非.co)更改为< strong> .co 。

我希望规则不为 examples.co ,而是变为 examples.co ,保留所有子域,但删除 www。< / strong>。

所有域都指向同一台服务器。但是www.subdomain.examples.co不会修剪www。并且不会将域名从.com更改为.co或更改为复数版本。

0 个答案:

没有答案