2014-02-13 23 views
-5

是的,这是另外一个问题.httaccess ...隐藏“的index.php”从URL,并得到参数

我向上帝发誓,我试图尽我所能,使这项工作,但我不能清楚地了解如何编写规则。

我想要的是:键入我的浏览器“mydomain.com/x/10”,它应该被解释为“mydonain.com/index.php?x=10”,所以我可以得到x值和用它。

我想这样做,所以很容易将东西链接到人。

我该怎么做?另外,如果有人能够提供给我一个链接,让我可以真正学习如何构建htaccess使用的正则表达式,那就太棒了。

+1

来吧,每一秒导致谷歌给出​​了一个完整的copypastable例子。 – gorelative

回答

2

是的,另一个的.htaccess的答案;)

Options +FollowSymLinks -MultiViews 

RewriteEngine On 
RewriteBase/

# Internally forward /x/10 to /index.php?x=10 
RewriteRule ^x/(.*)/?$ index.php?x=$1 [L,QSA,NC] 

这将重定向:

http://yourdomain.com/x/10 

内部到:

http://yourdomain.com/index.php?x=10 

所以用户不会看到,浏览器。


As for the link to learn about it, I found this a very good one specially because of the images describing what is going on.

+2

得到爱的排名在这些问题,一遍又一遍的upvote学分..大声笑 – gorelative

+1

@gorelative如果你觉得这样你应该提出它作为一个问题的调解人候选人,看看你是否可以改变的东西,因为我有过去尝试过,并且不是,所以SO不想改变。 – Prix

+0

如果我在本地主机上测试这个,在我的htdocs里的/ project文件夹中,我应该改变RewriteBase/to/project? –