如何在localhost中更改php页面的永久链接
I've seen that WordPress has a feature where you can change the permalink of your pages to different formats e.g. www.example.com/index.html
to www.example.com/index
.
How do you do that in localhost or in general any host without using WordPress for example if I have the page www.example.com/about.php
I want it to be search in a browsers address bar as www.example.com/about
Is there a way to do this?
我看到WordPress有一项功能,您可以将页面的永久链接更改为不同的格式,例如 您如何在localhost中执行此操作 或者一般情况下任何主机没有使用WordPress,例如,如果我有页面 有没有办法做到这一点? p>
div> www.example.com/index.html code>至
www.example.com/index code>。 p>
www.example.com/about.php code>我希望它在浏览器地址栏中搜索为
www.example。 com / about code> p>
Use .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
The code above will get rid of the .php
extension, thus giving you say index
instead of index.php
. And yes it works on localhost
and nearly all hosting companies include it.