1

I want to be able to use an .htacess file to allow the main domain only to be redirected, but not a subfolder of that domain.

Example; somesite.com redirects to something.somesite.com but allow somesite.com/example through to what is in the /example directory.

I did see a question similar to this one but could not understand the answer well enough to want to use the code.

4

1 回答 1

1

尝试将此添加到somesite.com的文档根目录中的 htaccess 文件中:

RedirectMatch 301 ^/$ http://something.somesite.com/ 

如果您更愿意使用 mod_rewrite:

RewriteEngine On
RewriteCond %{HTTP_HOST} somesite\.com$ [NC]
RewriteRule ^/?$ http://something.somesite.com/ [L,R=301]
于 2012-08-07T18:29:10.007 回答