【问题标题】:How to create .htaccess file that redirect short links into html files?如何创建将短链接重定向到 html 文件的 .htaccess 文件?
【发布时间】:2014-01-13 10:33:40
【问题描述】:

如何创建.htaccess 将短链接重定向到html 文件的文件? 例如。

    RewriteEngine On
    RewriteRule ^/start$ http://www.%{HTTP_HOST}/index.html [L]

上面的规则给了我一个404 error。我在主文件夹中有我的index.html

【问题讨论】:

    标签: html apache .htaccess mod-rewrite short


    【解决方案1】:

    那是因为前导斜线。试试这个:

    RewriteEngine On
    RewriteRule ^start/?$ /index.html [L]
    

    .htaccess 是每个目录指令,Apache 从 RewriteRule URI 模式中去除当前目录路径(因此是前导斜杠)。

    【讨论】:

    • 感谢您的解释。愚蠢的错误,但有多少价值 :) 有没有办法将 www.mydomain.pl 重定向到 www.mydomain.pl/start?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-17
    • 1970-01-01
    • 1970-01-01
    • 2011-01-04
    • 1970-01-01
    • 1970-01-01
    • 2016-10-31
    相关资源
    最近更新 更多