卸下PHP扩展与mod_rewrite的 [英] Removing the .php extension with mod_rewrite

查看:202
本文介绍了卸下PHP扩展与mod_rewrite的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要mod_rewrite的规则集,所以我可以指一个页面不带.php扩展名,但有重写包括PHP扩展。这将在1安培上运行; 1服务器

有什么好看的引用,以便我可以学到更多自己?


解决方案

  RewriteEngine叙述在
重写规则的东西something.php [L]

http://example.com/something ,就好像它是 something.php

要重定向的所有请求的是不是一个物理文件相同的名称,但名为.php的:

  RewriteEngine叙述在
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则(。*)$ 1.PHP [L]

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 will be handled as if it was a request for something.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
RewriteRule (.*) $1.php [L]

这篇关于卸下PHP扩展与mod_rewrite的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆