首页 > 关于 Apache 的.htaccess 问题

关于 Apache 的.htaccess 问题

大家好!我当前的需求是: 当输入的 url 地址为 http://www.lazyer.com/lazyer/frontend/web/site/login 时,强制重定向为http://www.lazyer.com/site/login。为此,我在服务器根目录写了一个.htaccess 文件,里面的代码如下:

<IfModule mod_rewrite.c>
    RewriteEngine On 
    RewriteBase / 

    RewriteCond %{HTTP_HOST} ^www\.lazyer\.com$
    RewriteCond %{REQUEST_URI} ^/lazyer/frontend/web/
    RewriteRule ^lazyer/frontend/web/(.*)$ http://www.lazyer.com/$1 [L,R=301]

</IfModule>

apache 也开启了 rewrite 功能,但是当输入http://www.lazyer.com/lazyer/frontend/web/site/login时,却没有重定向的效果。请问是怎么回事?


你URL里的Lazyer首字母是大写吧?规则里用的是少写。

建议你先写个绝对能匹配的规则,来验证配置是否有效。如:
RewriteRule .* http:://.com [R,NC]

【热门文章】
【热门文章】