开发者

How To Make Files With No Extention Behave As PHP

开发者 https://www.devze.com 2023-02-14 20:10 出处:网络
At this moment I have the following files in my directory: index.php about.php help.php I\'m using these lines in .htaccess to call the files using no extension.

At this moment I have the following files in my directory:

index.php
about.php
help.php

I'm using these lines in .htaccess to call the files using no extension.

RewriteCond %{REQUEST_FILENAME} !-d
R开发者_高级运维ewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

So sitename.com/index works as sitename.com/index.php

But I want to remove extensions completely. My directory would then look like this:

index
about
help

How to modify .htaccess to read some of these files as PHP and leave others untouched?


One possible solution would be to catch 404 errors.

You need to configure your web server to trigger a specific PHP page on error. That PHP page would then read the requested URL and include a file with the same name.

Here is some help to get started: onlamp.com


You probably can't do it with htaccess alone. You'll need to set your webserver to treat no-extension files as php files, and i'm not sure it can be done at all.

0

精彩评论

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