2015-04-03 57 views
0

我是新来重写,所以我甚至不知道这是可能的。如何重写一个无变量的url到一个包含变量的地址

我有这个网址:http://my.domain.com/index.php?CID=2

我要键入http://my.domain.com/meet-our-team和具有上述页面上来,而不显示真实的网址(的index.php CID = 2?)。

这是我在我的.htaccess文件:

RewriteEngine on 
RewriteRule ^meet-our-team$ index.php?CID=2 [NC,L] 

这似乎是我重定向到我的主页。我该如何做这个简单的重写?

谢谢 卢克

+0

这个规则没有重定向“用户”和“添加”值。尝试使用新的浏览器。还有更多规则吗? – anubhava 2015-04-03 20:53:17

回答

0

@syntrax - 谢谢,我还发现这些和其他类似的职位,但不能从他们那里得到多少帮助,由于这样的事实,我不相信我按照他们的意图使用重写规则。

我想要做的是创造任何海基会网址(例如example.com/this-is-my-sef-page),并将它指向的URL通常是这样的example.com/ index.php?catid = 1 $ id = 5

看起来好像所有我能做的就是改写什么在原来的网址,所以我需要使用这样的方法:http://moz.com/ugc/using-mod-rewrite-to-convert-dynamic-urls-to-seo-friendly-urls

这种方法不为我创造一个洁净足够海基会网址,所以我的解决方案是有效的URL列表会将所有点到我的index.php页面:

RewriteRule ^my-sef-url$ index.php 
RewriteRule ^my-other-sef-url$ index.php 

的index.php检查URL针对海基会之间的映射表,并显示基于数据库海基会映射相应的页面。这比创建复杂的.htaccess规则容易得多,并且允许我在我的sef url上有更多的灵活性。

0

例如,您需要使用mod_rewrite将相应的URL重写为.htaccess。

Desired URL = www.yoursite.com/index/users/add/ 



URL = www.yoursite.com/index.php?controller=users&option=add 



.htaccess code : 
RewriteRule ^index/(.*)/(.*)\.html index.php?controller=$1&option=$2 [QSA] 

所以你会得到GET方法变量

相关问题