开发者

Using .htaccess and mod_rewrite to not require file extensions in php pages [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. F开发者_运维百科or help making this question more broadly applicable, visit the help center. Closed 11 years ago.

Hopefully a quick URL rewrite question for you all.

I've got a page on my site: http://www.sample.com/whatever.php

and i'd like to be able to navigate the site without typing .php

so http://www.sample.com/whatever would show the same thing.

I'd like this to work for any file in the root directory, so users could use the extension or not.

Any thoughts?


As suggested in the comments above, I solved this issue using Apache's MultiViews

Adding the following to my .htaccess file did the trick:

Options +MultiViews
AddType application/x-httpd-php .php

Update: More details here: http://www.bmt-online.org/geekisms/php-multiviews


I'd say this should do it

htcaccess:

RewriteEngine on
RewriteBase /
RewriteRule whatever$ whatever.php
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜