mod_rewrite的清洁网址 [英] Mod_Rewrite for clean URL
本文介绍了mod_rewrite的清洁网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
真是简单的要求。我想我的网址看起来像:
的http://本地主机/电影/ 72105
而不是这个
的http://本地主机/电影ID = 72105
目前,我有我的.htaccess文件此设置怎么回事,但它似乎并不奏效:
RewriteEngine叙述上
< IfModule mod_rewrite.c>
RewriteEngine叙述上
重写规则^([A-Z \ - ] +)?$的index.php的id = $ 1 [L]
< / IfModule>
只是为了澄清藏汉,当mod_rewrite的工作是成功的,我还可以用它来获取ID:
$ _ GET ['身份证']
许多AP preciated任何帮助。
解决方案
< IfModule mod_rewrite.c>
RewriteEngine叙述上
重写规则^实验室/电影/(\ d +)$的index.php?编号= $ 1 [L]
< / IfModule>
现在,您可以浏览 http://domain.com/movie/12
和 $ _ GET ['身份证']
将 12
。
Really simple request. I want my url to look like:
http://localhost/movie/72105
instead of this
http://localhost/movie?id=72105
I currently have this setup going on in my .htaccess file, but it does not seem to be working:
RewriteEngine on
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([a-z\-]+)$ index.php?id=$1 [L]
</IfModule>
Just to clarify aswell, when the mod_rewrite is working successfully, I can still use to retrieve the ID?:
$_GET['id']
Much appreciated for any help.
解决方案
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^lab/movie/(\d+)$ index.php?id=$1 [L]
</IfModule>
Now, you can browse http://domain.com/movie/12
and $_GET['id']
will be 12
.
这篇关于mod_rewrite的清洁网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文