Redirecting localhost/xxx to localhost/xxx.php in WAMP

送分小仙女□ 提交于 2019-12-13 18:11:34

问题


In Ubuntu/Mac, going to, say, localhost/page automatically redirects to localhost/page.php.

But this doesn't work in Windows. How do you make stuff like localhost/asdf redirect to localhost/asdf.php?


回答1:


I am assuming that you know what an .htaccess file is.

You can achieve this by two methods:

Method 1:

`#1- Loads the page asdf.php but 
     displays asdf in the address bar  

RewriteBase   /site  
RewriteRule ^([^/\.]+)?$ $1.php `  

Method 2:

`#2- Loads the page asdf.php and 
displays asdf.php in the address bar. 
The R flag tells Apache to redirect to the
url. 

RewriteBase   /site  
RewriteRule ^([^/\.]+)?$ $1.php [R]`  

I hope this will help you.



来源:https://stackoverflow.com/questions/6868535/redirecting-localhost-xxx-to-localhost-xxx-php-in-wamp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!