重定向本地主机/ XXX为localhost /在WAMP xxx.php重定向、主机、XXX、localhost

2023-09-02 10:03:04 作者:我本无心何来变心、

在Ubuntu的/ Mac上,去,说,本地主机/页自动重定向到l​​ocalhost / page.php。

但是,这并不在Windows中工作。如何做才能让你的东西,如本地主机/航空自卫队重定向到l​​ocalhost / asdf.php?

解决方案   

我假设你知道一个.htaccess文件。

您可以通过两种方法实现这一点:

方法1:

 `#1加载页面asdf.php但
     航空自卫队显示在地址栏

的RewriteBase /网站
重写规则^([^ / 。] +)?$ $ 1.PHP`
 
在本地输入localhost连接到本地计算机名 有图看下

方法2:

 `#2加载页面asdf.php和
显示asdf.php在地址栏。
在R标志告诉Apache重定向到
网址。

的RewriteBase /网站
重写规则^([^ / 。] +)?$ $ 1.PHP [R]`
 

我希望这会帮助你。

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?

解决方案

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.

 
精彩推荐
图片推荐