我正在尝試將Portal.example.com以外的所有子域从任何埠(通常是80或443)重定向到埠30000。
例如
- example.com: (any port) shall have no change
- www.example.com: (any port) shall have no change
- portal.example.com (any port) shall have no change
- a.example.com (any port) shall be updated to a.example.com:30000
- b.example.com (any port) shall be updated to b.example.com:30000
- *.example.com (any port) shall be updated to *.example.com:30000
- etc.
我目前有關註
.htaccess
,直接指匯example.com和* .example.com:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
最新回復
- 5月前1 #
- 5月前2 #
請按照您顯示的示例編寫的內容尝試以下內容.在測試URL之前,請確保清除瀏覽器快取。
RewriteEngine ON RewriteCond !^example\.com [NC] RewriteCond !^www\.example\.com [NC] RewriteCond !^portal\.example\.com [NC] RewriteCond (.*example\.com) [NC] RewriteCond %{SERVER_PORT} !^30000$ RewriteRule ^(.*)$ http://%{HTTP_HOST}:30000%{REQUEST_URI} [R=301,NE,L]
相似問題
- apache:htaccess用雜湊重定向到子域URLapachehtaccessredirectmodrewritehttpstatuscode3012021-01-02 22:22
- regex:使用htaccess从網址中删除" indexphp"regexapachehtaccessmodrewriteredirect2021-01-08 06:23
- apache:如何根据查詢字元串重定向URL?apachehtaccessmodrewriteredirect2021-01-07 21:25
- apache:CSS,JS和圖像無法以漂亮的網址顯示apachehtaccessurlmodrewriteredirect2021-01-07 03:26
- apache:重定向410網址格式apachehtaccessredirectmodrewrite2021-01-04 23:53
一些重構規則: