【问题标题】:How do I make www.example.com/file redirect to www.example.com/file.doc?如何使 www.example.com/file 重定向到 www.example.com/file.doc?
【发布时间】:2011-07-17 17:38:25
【问题描述】:

如何让www.example.com/file 重定向到www.example.com/file.doc

额外信息:

  • 我正在运行 apache
  • 我正在使用 ubuntu bitnami-wordpress AMI 运行 Amazon EC2 实例

【问题讨论】:

    标签: html apache redirect web


    【解决方案1】:
    RewriteEngine on
    

    通用规则:

    RewriteRule ^(.+)$ $1.doc [L]
    

    你的出现:

    RewriteRule ^file$ file.doc [L]
    

    【讨论】:

    • 我该怎么做?使用腻子?
    • 你需要把这段代码放到.htaccess文件看here例如
    【解决方案2】:

    您实际上可以在没有mod_rewrite 的情况下使用MultiViews 和Apache httpd 的Content Negotiation

    但请注意,这对现有的重写规则有一些严重影响。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-11
      • 1970-01-01
      • 2017-10-26
      • 1970-01-01
      • 1970-01-01
      • 2012-10-17
      相关资源
      最近更新 更多