当前位置: 动力学知识库 > 问答 > 编程问答 >

.htaccess - My htaccess redirect rule is not working for my subdomain

问题描述:

What I am trying to do is redirect all requests coming from

blog.domain.com to www.domain.com/blog

Here is what I have tried so far based on this answer on SO:

<IfModule mod_rewrite.c>

RewriteCond %{HTTP_HOST} ^blog\.domain\.com$

RewriteCond %{THE_REQUEST} ^GET

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

</IfModule>

What am I doing wrong? How do I fix this?

网友答案:

Have you started the RewriteEngine? Make sure you have this somewhere before your .htaccess rules:

RewriteEngine on
RewriteBase /

Without these, Apache's Rewrite engine won't recognize these rules, and won't start parsing them as you expect.

分享给朋友:
您可能感兴趣的文章:
随机阅读: