问题描述:

I've been trying to get this working on a community site which launches tomorrow, the site has 7 subdomains for each community in the project. Annoyingly the person running it has printed posters with:

www.subdomain.domain.com

My latest attempt to fix this through htaccess is:

AddType x-httpd-php53 .php

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]

RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

</IfModule>

Deadline is tight so any help would be great, thanks.

网友答案:

redirect www.subdomain.domain.com to subdomain.domain.com

You can use:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^www\.([^.]+\.domain\.com)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]
</IfModule>
相关阅读:
Top