0

I've been trying to rewrite the following URL:

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

to:

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

This is what I came up with after researching:

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

But that didn't work, I ended up on a 404 error page. My .htaccess file is stored in the root of my website (not the subdomain folder), if that is any help.

How could I get this to work?

Thanks,
Daviga404

4

1 回答 1

0

你似乎有这样的目录

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

如果您的子域的 DocumentRoot 是 SubDomain 目录,您应该将您的 .htaccess 文件放在 SubDomain 目录中并简单地使用 RewriteRule 指令:

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

希望这有帮助

咪咪兹

于 2012-06-07T20:42:21.653 回答