开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜