htaccess子域名RewriteRule

时间:2012-06-07 20:19:07

标签: apache .htaccess mod-rewrite subdomain

我一直在尝试重写以下网址:

  

http://subdomain.domain.com/pages/my100page.html

为:

  

http://subdomain.domain.com/index.php?id=my100page

这是我在研究后提出的:

  

RewriteEngine On
RewriteCond%{HTTP_HOST} ^ subdomain.domain.com $ [NC]
RewriteRule ^ pages /([^ /] *)。html $ /index.php?id=$1 [L,R = 301]

但是那不起作用,我最终在404错误页面上。我的.htaccess文件存储在我的网站的根目录(不是子域文件夹)中,如果有任何帮助的话。

我怎么能让这个工作?

谢谢,
Daviga404

1 个答案:

答案 0 :(得分:0)

你似乎有这样的目录

MainSite/
  ---SubDomain/
  ---.htaccess

如果子域的DocumentRoot是SubDomain目录,则应将.htaccess文件放在SubDomain目录中,只需使用RewriteRule指令:

RewriteEngine On
RewriteRule ^pages/([^/]*).html$ /index.php?id=$1 [L,R=301]

希望这个帮助

Mimiz

相关问题