开发者

add file-ending using .htaccess?

I'm trying to add a file-ending (.kml) to a url using .htaccess but it's not working

The url is http://resihop.nu/kml I want it to be http开发者_运维知识库://resihop.nu/kml.kml this is what i tried:

RewriteRule ^kml.kml$ kml

Here is my full .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


You need to tell the server how to handle .kml files. Add this line to your .htaccess:

AddType application/x-httpd-php .kml

(Assumes you want .kml files to be parsed as PHP.)

Edit: Never mind, I just re-read your question and I realise that's not your problem. Just ignore me!


This should work for your case of using your own extension:

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

Then you could access any file with the .kml extension, such as hello.kml.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜