![](/img/trans.png)
[英]htaccess redirect <hostname>/?area=0 to <hostname>/
[英]htaccess redirect if hostname is NOT
我正在運行具有多個虛擬主機的服務器,並且將phpMyadmin設置為可以通過anydomain.com/phpmyadmin訪問的別名。 我想使用.htaccess重定向規則,以便如果未在server-admin-url上訪問phpmyadmin,則將訪問者重定向到Google。
正確的URL為: https://server.domain.com:9090/phpmyadmin
: https://server.domain.com:9090/phpmyadmin
: https://server.domain.com:9090/phpmyadmin
有人可以幫我嗎?
謝謝!
最簡單的方法
RewriteEngine On
RewriteCond %{HTTP_HOST} !^server.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.google.com/$1 [L,R]
也許您還想檢查端口,然后使用
RewriteCond %{SERVER_PORT} !^9090$ [OR]
RewriteCond %{HTTP_HOST} !^server.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.google.com/$1 [L,R]
更新
再次閱讀您的問題,我發現您也在嘗試從http切換為https。
我建議檢查https是否關閉:
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^server.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.google.com/$1 [L,R]
如果您的VirtualHost配置了https,則應特別注意VirtualHost匹配的工作方式
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.