mod_rewrite,/index.php?p = test到/test [英] mod_rewrite, /index.php?p=test to /test

查看:52
本文介绍了mod_rewrite,/index.php?p = test到/test的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在.htaccess文件中设置一个非常简单的规则,以重写此类网址:www.domain.com/index.php?page=test到以下网址:www.domain.com/test

我是mod_rewrite的新手,到目前为止,我已经遵循了此规则

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule ^(.*)$ index.php?$1

但它不起作用.

有帮助吗? 非常感谢

解决方案

几乎是,您只是忘记了page=:

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

现在请注意,此规则的作用正好相反:它将内部诸如/test之类的路径请求重写为/index.php?page=test,反之亦然.

i'm trying to set up a very simple rule in .htaccess file in order to rewrite this kind of url: www.domain.com/index.php?page=test to this: www.domain.com/test

I'm newbie to mod_rewrite, and so far, i came to this rule

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule ^(.*)$ index.php?$1

but it doesn't work.

Any help? Thanks a lot

解决方案

Almost right, you just forgot the page=:

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

Now note that this rule does the exact opposite: It rewrites requests of paths like /test internally to /index.php?page=test and not vice versa.

这篇关于mod_rewrite,/index.php?p = test到/test的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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