using mod_rewrite to redirect from subdomain to maindomain

后端 未结 3 1663
挽巷
挽巷 2021-01-25 16:15

My problem is that i have a functioning subdomain (sub.mydomain.com). sub is loaded in mydomain.com/sub.

What i would like to do is to redirect all requests to sub.mydom

3条回答
  •  盖世英雄少女心
    2021-01-25 16:28

    It's difficult to provide a definitive answer without knowing more about your server configuration.

    The following might work and is at the very least a decent starting point:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^sub\.mydomain\.com 
    RewriteRule (.*) /$1 [L]
    

    Ideally that would go in your httpd.conf, but might work from a .htaccess file (again, more information about how your subdomains are setup would be helpful).

提交回复
热议问题