【问题标题】:.htaccess - redirect a php File to an Virtual Directory.htaccess - 将 php 文件重定向到虚拟目录
【发布时间】:2011-12-26 15:06:03
【问题描述】:

从 PHP 文件创建虚拟目录的 .htaccess 行是什么?

www.domain.de/file.php 应该转到www.domain.de/file/

【问题讨论】:

    标签: php .htaccess directory virtual


    【解决方案1】:

    就是这样:

    DirectoryIndex index.php
    RewriteEngine on
    RewriteRule ^file/ file.php [L]
    Options -Indexes
    

    【讨论】:

      【解决方案2】:

      类似这样的:

      RewriteEngine On
      RewriteRule ^(.+)\.php$ /$1/ [L]
      

      这将使如果您输入http://www.domain.de/something/,网络服务器会将URI 重写为/something.php。你只需要确保你的链接是/something/

      【讨论】:

      • 谢谢,但不是这样。当然,这会使 index.php 出错。我想重定向单个 php 文件。你能帮帮我吗?
      猜你喜欢
      • 1970-01-01
      • 2014-09-28
      • 2011-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多