【问题标题】:Redirecting localhost/xxx to localhost/xxx.php in WAMP在 WAMP 中将 localhost/xxx 重定向到 localhost/xxx.php
【发布时间】:2011-07-29 04:09:39
【问题描述】:
在 Ubuntu/Mac 中,例如 localhost/page 会自动重定向到 localhost/page.php。
但这在 Windows 中不起作用。如何让 localhost/asdf 之类的东西重定向到 localhost/asdf.php?
【问题讨论】:
标签:
php
.htaccess
wamp
wampserver
【解决方案1】:
我假设您知道 .htaccess 文件是什么。
您可以通过两种方法来实现:
方法一:
`#1- Loads the page asdf.php but
displays asdf in the address bar
RewriteBase /site
RewriteRule ^([^/\.]+)?$ $1.php `
方法二:
`#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]`
希望对你有帮助。