【问题标题】:My Apache rewrite rule does't work as my wish我的 Apache 重写规则不能如我所愿
【发布时间】:2013-10-10 01:53:42
【问题描述】:

我有一个网站 shop.example.com。 我想做一个重写来实现这样的: 浏览器输入 shop.example.com ----> /shop/index.php(服务器端) 我这样写规则:

RewriteEngine on  
RewriteCond %{HTTP_HOST} ^shop.example.com [NC] 
RewriteRule ^$ shop/index.php

它不起作用,浏览器什么也没显示。 当我像这样更改规则时:

RewriteEngine on  
RewriteCond %{HTTP_HOST} ^shop.example.com [NC] 
RewriteRule ^ssssssssss $ shop/index.php

当浏览器输入 shop.example.com/ssssssssss ----> /shop/index.php 时它确实有效 为什么?我该怎么办? 请告诉我!非常感谢!

【问题讨论】:

    标签: apache .htaccess mod-rewrite


    【解决方案1】:

    你可以试试:

    RewriteEngine on  
    RewriteCond %{HTTP_HOST} ^shop\.example\.com$ [NC] 
    RewriteRule ^/?$ /shop/index.php [L]
    

    【讨论】:

    • 我得到了真正的原因并以另一种方式解决它......仍然感谢你。
    • 为了 SO 用户的利益,您应该发布您的解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-02
    • 2011-10-26
    • 1970-01-01
    相关资源
    最近更新 更多