URL重写GET参数(URL Rewrite GET parameters)

   IT问题网   2018-03-07 00:00:00

问 题

我希望我的网址如下所示

www.website.com/homeamp;foo=baramp;hello=world

我只想要第一个get参数更改

然而实际的"幕后"的网址就是这个

www.website.com/index.phppage=homeamp;foo=baramp;hello=world

所有教程我发现改变所有的参数。

任何帮助非常ap preciated!

解决方案

添加到您的的.htaccess 在web根 / 目录

rewriteengine叙述上
的rewritebase /

?重写规则^家$ index.php页面=家庭及放大器;%{query_string} [nc,l]
 

如果你想要这个工作的所有网页,即 /任何页面被担任的index.php?页=所有页然后用

rewriteengine叙述上
的rewritebase /

的rewritecond%{} request_filename!-d#不是一个目录
的rewritecond%{} request_filename!-f#不是一个文件
(。*)重写规则^ $的index.php 1页= $&放大器;%{query_string} [nc,l]
 


如何将这些规则的工作?

a 重写规则语法如下

 重写规则[图案] [替换] [国旗]
 

模式的可使用普通的前pression并且匹配的主机名和端口(与的.htaccess 放在根目录),但任何查询字符串之前。

第一条

该模式 ^家$ 使得第一条规则匹配传入的urlwww.website.com/home 。该%{query_string} 简单的捕捉和后追加什么的/ home?的内部取代网址的index.php?页=家里。

标志 nc 只是使规则不区分大小写的,因此它匹配 /首页或 / home 为好。而→简单地将其标记为去年即改写的情况下有如下定义的任何其他规则应该到此为止。

第二条

这一次只是比较通用的,即如果所有的网站页面的编写遵循一些规则,每个页面的这个url模式则相反,我们可以只使用这个通用的。

在。* 模式中的 ^(。*)$ 匹配 /任何-page名和括号有助于捕捉的任何页面名称部分为 $ 1 在替换url作为的index.php?page变量= $ 1 。该&安培; 在页=家庭及放大器;1 页= $&安培; 简直是多个查询字符串字段值对之间使用的分隔符。

最后,%{query_string} 和 [nc,l] 标记的工作方式相同的规则之一。

标签:重写参数



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

htaccess的从XAMPP转向灯开的Ubuntu 13.10后不工作(启用htaccess的Apache中的Linux服务器)(htaccess is not working after moving from XAMPP to LAMP on ubuntu 13.10 (Enable htaccess in apache linux server))

problem my codeigniter project is running successfullyon ...

查询字符串和放大器;国防部重写(Query Strings & Mod ReWrite)

problem i'm not too inexperienced with rewrite (not a mas ...

在.xml文件PHP的错误?(PHP error in .xml file)

problem ok firstly, i added this line to my .htaccess fil ...

使用Apache的mod_rewrite解析搜索引擎友好的URL(using apache's mod_rewrite to parse SEO friendly URL's)

problem how do i convert something like me.com/profile/2 ...

搜索引擎友好的URL(Search-Engine Friendly URLs)

problem i am working on building my first search-engine f ...

斜杠之后将文字与.htaccess的变量(Turn text after slashes into variables with HTACCESS)

problem i need to pass 3 variables with a url but using s ...

从URL删除字符与htaccess的(Remove Characters from URL with htaccess)

problem hopefully someone can see what i'm do ...

重定向所有的HTML扩展到.PHP(redirect all .html extensions to .php)

problem i want to update all the pages on a website to us ...

需要转义#(哈希/磅)字符在.htaccess重写规则(need to escape # (hash/pound) character in .htaccess rewrite rule)

problem the question is fairly simple but i w ...

如何使用的.htaccess重写规则改变下划线以破折号(How do I use .htaccess RewriteRule to change underscores to dashes)

problem i'm working on a site, and its cms used to save n ...

请求实体太大PHP(Request Entity Too Large PHP)

problem in one of my cakephp site, i got this error. req ...

的.htaccess使用PHP $ _GET缩短网址(.htaccess shorten URL using php $_GET)

problem i need to be able to shorten my page from: mydom ...

Gzip已融为一体pression通过的.htaccess不工作(Gzip compression through .htaccess not working)

problem i have been creating a site and checking it's spe ...

重定向www.subdomain.example.com到subdomain.example.com(redirecting www.subdomain.example.com to subdomain.example.com)

problem i've had some users trying to access a site that ...

添加尾随斜线的.htaccess(Add Trailing Slash .htaccess)

problem i'm trying to get the following effec ...

禁用所有的CGI(PHP,PERL,...)使用的.htaccess目录(Disable all CGI (php, perl, …) for a directory using .htaccess)

problem i have a directory where users can upload files. ...

在某个目录设置为仅附件上的文件内容处理标头?(Set Content-Disposition header to attachment only on files in a certain directory)

problem i've got this this rule in my htaccess file to fo ...

阿帕奇升级到2.4后,内部URL重写不再工作(Internal URL rewrite no longer working after upgrading Apache to 2.4)

problem i need to internally rewrite the base url so that ...

使用codeigniter共享托管服务器上的困惑(Puzzled using codeigniter on shared hosting server)

problem this ones a new on me. i'm transferring a site i ...

通过用户代理或空的查询块(Block by useragent or empty referer)

problem a stranger bot (gbplugin) is codifying the urls o ...