【问题标题】:add file-ending using .htaccess?使用.htaccess 添加文件结尾?
【发布时间】:2011-05-26 12:33:02
【问题描述】:

我正在尝试使用 .htaccess 将文件结尾 (.kml) 添加到 url,但它不起作用

网址是http://resihop.nu/kml 我希望它是 http://resihop.nu/kml.kml 这是我尝试过的:

重写规则 ^kml.kml$ kml

这是我的完整 .htacess:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
    Order Deny,Allow
    Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

RewriteRule ^kml\.kml$ kml

【问题讨论】:

    标签: apache .htaccess


    【解决方案1】:

    您需要告诉服务器如何处理 .kml 文件。将此行添加到您的.htaccess

    AddType application/x-httpd-php .kml
    

    (假设您希望将 .kml 文件解析为 PHP。)

    编辑:没关系,我只是重新阅读了您的问题,我意识到这不是您的问题。别理我!

    【讨论】:

      【解决方案2】:

      这应该适用于您使用自己的扩展程序的情况:

      Options +FollowSymlinks
      RewriteEngine On
      RewriteBase /
      RewriteRule ^(.+)\.kml$ /$1.php [NC,L]
      

      然后您可以访问任何扩展名为 .kml 的文件,例如 hello.kml。

      希望这会有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-03-09
        • 1970-01-01
        • 1970-01-01
        • 2012-08-03
        • 1970-01-01
        • 2012-06-01
        • 1970-01-01
        • 2023-04-08
        相关资源
        最近更新 更多