[英]Renaming PHP files to something other than .php
This might seem like a very easy answer but I cant seem to wrap my head around it.这似乎是一个非常简单的答案,但我似乎无法理解它。 How would I rename files?
我将如何重命名文件? For instance if I wanted to rename index.php to "home" or something.
例如,如果我想将 index.php 重命名为“home”之类的。 How would I go about doing that?
我将如何 go 这样做?
Also, how would I rename user pages?另外,我将如何重命名用户页面? Instead of example.com/profile.php?id=28, something like example.com/users/mrexample
而不是 example.com/profile.php?id=28,类似于 example.com/users/mrexample
Thanks a bunch guys!谢谢一群人!
You can call them whatever you like, so long as the web server understands that they need to be handled as PHP scripts.您可以随意调用它们,只要 web 服务器了解它们需要作为 PHP 脚本处理即可。 One common mechanism for doing this under HTTPd is mod_rewrite .
在 HTTPd 下执行此操作的一种常见机制是mod_rewrite 。
Assuming you want to keep the existing file structure on the server and present pretty URLs as you described, this is called URL Routing.假设您想在服务器上保留现有文件结构并按照您的描述呈现漂亮的 URL,这称为 URL 路由。 If you're using Apache then
mod_rewrite
is the way to go.如果您使用的是 Apache,那么
mod_rewrite
是 go 的方式。 Lighttpd also supports rewrites. Lighttpd 还支持重写。 I believe a commercial rewrite plugin is available for IIS.
我相信 IIS 可以使用商业重写插件。
You can either create a set of rewrite rules that match URL queries and pass them on to the relevant PHP file, or have a single rewrite rule that forwards all requests to a single PHP script which calls the appropriate function/script/template/include.您可以创建一组与 URL 查询匹配的重写规则并将它们传递到相关的 PHP 文件,或者具有将所有请求转发到单个 Z2FEC392304A5C23AC138DA22847 脚本的单个重写规则。
Hope that helps希望有帮助
This will help you a lot and solve your problem这将对您有很大帮助并解决您的问题
http://corz.org/serv/tricks/htaccess2.php http://corz.org/serv/tricks/htaccess2.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.