我们的网站有这个网址
http://mydomain.com/blog.php?id=50
并需要将其重定向到
http://blogs.mydomain.com/blog.php?id=50
必须创建子域或文件夹,还是我们可以直接创建.htaccess文件?
答案 0 :(得分:2)
在.htaccess文件中尝试以下内容
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain\.com [NC]
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^blog\.php$ http://blogs.mydomain.com/blog.php?id=%1 [L,R=301]