开发者

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

开发者 https://www.devze.com 2023-03-24 05:21 出处:网络
In Ubuntu/Mac, going to, say, localhost/page automatically redirects to localhost/page.开发者_JAVA百科php.

In Ubuntu/Mac, going to, say, localhost/page automatically redirects to localhost/page.开发者_JAVA百科php.

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


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.

0

精彩评论

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