简体   繁体   中英

Load php page without user having to type '.php' in browser

I have a webpage: http://www.somename.com/webapp.php

I'd like users to be able to get to it be simply typing http://www.somename.com/webapp

I know this would work if the page was an html page ('webapp.html').

Any ideas on how I can make this work? Is there a configuration file I can edit to get the desired behavior?

I have two ideas, but they seem clunky to me:
1) make a webapp.html and have it redirect to webapp.php
2) make webapp.html and iframe webapp.php inside of it

Thanks!

If you are using Apache with mod_rewrite, you can add these lines to your .htaccess

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [L]

This will map hostname.com/webstore to hostname.com/webstore.php

简单的解决方案:制作一个文件夹webapp/ ,将脚本移到其中,并将其重命名为index.php ;-)

Put this in your .htaccess file:

Options +MultiViews

This will turn on content negotiation and automatically look for a matching file when no extension is given.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM