是否有可能隐藏GET变量中的一个通过的.htaccess重定向? [英] Is it possible to hide one of the GET variables through .htaccess redirect?
问题描述
假设我经过4个变量通过GET方法,比如 game_name
, game_id
, game_category
, game_player
。
Suppose I am passing 4 variables through get method, say game_name
, game_id
, game_category
, game_player
.
默认链接看起来是这样的: <$c$c>www.games.com/gameinfo?game_name=zxcvb&game_id=12345&game_category=foo&game_player=bar$c$c>
the default link would look something like this:
www.games.com/gameinfo?game_name=zxcvb&game_id=12345&game_category=foo&game_player=bar
现在,我要重写喜欢的网址:
www.abc.com/gameinfo/foo/zxcvb/bar
Now, I want to rewrite the URL like:
www.abc.com/gameinfo/foo/zxcvb/bar
我不希望展示游戏中的链接的ID,但仍然希望得到它通过使用 GET
方法。
I do not want to show the id of the game in the link but still want to get it passed using GET
method.
如何才能做到这一点?
推荐答案
到的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 /
# From: /gameinfo/12345/foo/zxcvb/bar
# To: /gameinfo?game_name=zxcvb&game_id=12345&game_category=foo&game_player=bar
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(gameinfo)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /$1?game_name=$2&game_id=$3&game_category=$4&game_player=$5 [L,QSA,NC]
这篇关于是否有可能隐藏GET变量中的一个通过的.htaccess重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!