在.htaccess重写查询字符串 [英] Rewrite query string in .htaccess

查看:329
本文介绍了在.htaccess重写查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个查询字符串的一个非常简单的重写和我有没有运气可言。我需要从

I'm trying to do a very simple rewrite of a query string and I'm having no luck at all. I need to go from

HTTP://例如点com / ACT = jQuery的

http:// example dot com/?ACT=jquery

HTTP://例如点com / index.php的ACT =的jQuery

http:// example dot com/index.php?ACT=jquery

这是我写在我的.htaccess文件中的code和它抛出了我一个内部服务器错误。我真的在这个新的全mod-rewrite业务,所以任何帮助将大大AP preciated。

This is the code that I've written in my .htaccess file and it throws me an internal server error. I'm really new at this whole mod rewrite business so any help would be greatly appreciated.

RewriteEngine叙述在
的RewriteCond%{QUERY_STRING} ^(ACT = jQuery的)$
重写规则^(。*)$的index.php /?act =被jQuery的

RewriteEngine On
RewriteCond %{query_string} ^(ACT=jquery)$
RewriteRule ^(.*)$ index.php/?ACT=jquery

推荐答案

如果你只是希望它拿起PHP文件,不需事先告知浏览器:

If you just want it to pick up the php file without informing the browser:

RewriteEngine On
RewriteRule ^/\?ACT=jquery$ index.php/?ACT=jquery [PT,L]

如果您希望浏览器更改书签等创建cononical网址:​​

If you want the browser to change bookmarks etc. to create a cononical URL:

RewriteEngine On
RewriteRule ^/\?ACT=jquery$ index.php/?ACT=jquery [R=301,L]

假设任意参数:

Assuming arbitrary arguments:

RewriteEngine On
RewriteRule ^/\?(.*)$ index.php/?$1 [PT,L]

或者,你可能preFER脚本别名:

Or you might prefer a script alias:

ScriptAliasMatch ^(.*)\?(.*)$ index.php

这篇关于在.htaccess重写查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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