从网站URL隐藏index.php

时间:2010-04-17 17:30:15

标签: .htaccess redirect

我正在使用htaccess重写引擎让网址看起来不错, 从www.mysite.com/index.php?pag=home到www.mysite.com/pag/home

它适用于此规则

RewriteRule ^pag/([^/]+)$ index.php?pag=$1 [L,QSA,NC]

但是当我访问www.mysite.com时,它会将我重定向到www.mysite.com/index.php 有没有办法重定向到www.mysite.com/pag/home?

我试过

redirect 301 /index.php http://www.mysite.com/pag/home

但是当我尝试访问www.mysite.com时,浏览器会给我的“页面不存在错误”

2 个答案:

答案 0 :(得分:0)

这是Drupal用来制作漂亮网址的规则,你的应该非常相似: RewriteRule ^(。*)$ index.php?q = $ 1 [L,QSA]

您的规则仅匹配其中包含pag的网址,但您真的想要点击每个网址。

答案 1 :(得分:0)

问题出在此重定向规则

redirect 301 /index.htm http://www.mysite.com/index.php
相关问题