简单的Mod重写 [英] Simple Mod Rewrite

查看:48
本文介绍了简单的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重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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