Tough One - .htaccess redirect subfolder while using wildcards

Discussion in 'Apache' started by mdvaldosta, Mar 18, 2008.

  1. #1
    How would you 301 redirect calls for /folder to www version of website, without interfering with wildcard subdomains?

    The issue is, with WordpressMu for example, users will create blogs on subdomains... which is great. Unfortunately, say I installed a forum for support in a /forum directory - any call for /forum will work (bad, duplicate content).

    www.example.com/forum = good
    abc.example.com/forum = bad
    efg.example.com/forum = bad

    Yet they all work. Can anyone crack this?
     
    mdvaldosta, Mar 18, 2008 IP
  2. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #2
    RewriteCond %{HTTP_HOST} (example\.com)$ [NC]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^/?(forum.*)$ http://www.%1/$1 [R=301,NC]
    Code (markup):
    (forum.*) may need to be refined a little depending on what's possible.
     
    joebert, Mar 19, 2008 IP