简单的 Mod 重写

Simple Mod Rewrite(简单的 Mod 重写)
本文介绍了简单的 Mod 重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试创建一个 mod 重写来简单地打开这些链接:

I'm trying to create a mod rewrite to simply turn these links:

/index.php?page=home
/?page=home

进入

/home

有人可以告诉我这是怎么做的吗?在我们讨论这个主题时,是否有任何关于 mod 重写的好资源可供阅读?到目前为止,我最大的困难是我看不到任何调试它的方法.事情要么有效,要么无效.

Can someone show me how this is done? While we're on the subject, are there any good resources to read up on mod rewrite? My biggest struggle so far is that I don't see any way of debugging it; things either work or they don't.

推荐答案

有多种方法可以做到这一点.这个规则适用于任何不存在的文件:

There are a variety of ways to do this. This one applies the rule to any non-existent file:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L]

您可能需要在顶部添加 RewriteEngine on,这会在您的 Web 文档根目录中的 .htaccess 中添加.当然,所有这些都取决于您的 Web 主机是否允许使用 htaccess (mod_rewrite) 以及规则覆盖文件是否应命名为 .htaccess.不过两者都很常见,所以应该没有问题.

You may have to add RewriteEngine on at the top, and this goes in .htaccess in your web document root. All of this, of course, depends on whether use of htaccess (mod_rewrite) is allowed by your web host and whether the rule override file should be named .htaccess. Both are pretty common though, so it shouldn't be a problem.

这篇关于简单的 Mod 重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)