使用 mod_rewrite 删除 .php 扩展名 [英] Removing the .php extension with mod_rewrite
本文介绍了使用 mod_rewrite 删除 .php 扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个 mod_rewrite 规则集,这样我就可以引用没有 .php 扩展名的页面,但要重写它以包含 .php 扩展名.这将在 1&1 服务器上运行.
I want a mod_rewrite rule set, so I can refer to a page without the .php extension, but have that rewritten to include the .php extension. This will be running on a 1&1 server.
有什么好的参考资料可以让我自己学习更多吗?
Are there any good references so I can learn more myself?
推荐答案
RewriteEngine On
RewriteRule something something.php [L]
http://example.com/something
将被视为对 something.php
将所有不是物理文件的请求重定向到同名但使用.php:
To redirect all requests that are not a physical file to the same name but with .php:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule (.*) $1.php [L]
这篇关于使用 mod_rewrite 删除 .php 扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文