htaccess的重写GET变量的URL,但仍然有机会获得他们 [英] htaccess Rewrite GET variables in URL, but still have access to them
本文介绍了htaccess的重写GET变量的URL,但仍然有机会获得他们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图把东西在我的.htaccess文件中,这将让我改变了以下网址:
I am trying to put something in my .htaccess file that will allow me to change the following URL:
http://www.mysite.com/profile?user=theuser
要这样的:
http://www.mysite.com/profile/theuser
而在页面上,仍然可以做一些事情,如:
But in the page, still be able to do something like:
echo $_GET['user']; // echos "theuser"
这可能吗?我将如何做到这一点?
Is this possible? How would I do this?
注:我想获得的URL地址栏中显示 http://www.mysite.com/profile/theuser
NOTE: I am trying to get the URL in the address bar to show http://www.mysite.com/profile/theuser
推荐答案
到的httpd.conf
启用了mod_rewrite和.htaccess,然后把这个code在< $ C C>的.htaccess $ DOCUMENT_ROOT
目录下:
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(profile)/(theuser)/?$ $1?user=$2 [L,QSA,NC]
这篇关于htaccess的重写GET变量的URL,但仍然有机会获得他们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文