如何删除使用的.htaccess规则PHP扩展? [英] How can I remove the .php extension using .htaccess rules?

查看:283
本文介绍了如何删除使用的.htaccess规则PHP扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为我的.htaccess文件带走的.php文件扩展名,并将其与刚刚斜线替换。

I need for my .htaccess file to take away the .php file extension and replace it with just a trailing slash.

另外,我有一个profile.php页面,该页面通常会拜访了一位数字查询字符串参数,如 profile.php?ID = 3

Also, I have a profile.php page which will normally be visited with a numeric querystring parameter, like "profile.php?id=3".

于是就用斜杠替换扩展,如何使 profile.php?ID = 3 看起来像简介/ 3的顶部/

So on top of replacing extensions with slashes, how do I make "profile.php?id=3" look like "profile/3/"?

到目前为止,我只有第一行:

So far all I have is the first line:

RewriteEngine on

我在哪里何去何从?

Where do I go from here?

推荐答案

如果你这么新的...你真的应该的阅读本手册

If you're so new... you really should read the manual.

// if not a file
RewriteCond %{SCRIPT_FILENAME} !-f
// if not a directory
RewriteCond %{SCRIPT_FILENAME} !-d
// pass all params back to index.php
// QSA stands for query string append
// L stands for last rule
RewriteRule (.*) index.php?$1 [QSA,L]

但是,这将做你想做的。现在,不要偷懒。阅读手册!

But this will do what you want. Now don't be lazy. Read the manual!

这篇关于如何删除使用的.htaccess规则PHP扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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