2014-10-17 84 views
1

你好今天我试图改写几件事情,我想改写这个:的.htaccess问号允许

www.example.com/index.php?title=how+do+man+live? 

要:

www.example.com/posts/how+do+man+live?/ 

现在的问题是问号只能出现在URL和当我发布$ _GET变量(标题..)其后发布的一切,但不是问号。

我试图把在改写MDOE这样的:

RewriteRule post/([0-9א-בa-zA-Z+.`?]+)/?$ index.php?title=$1 [NC] 

课程,重写引擎上。 谢谢你们,祝你有美好的一天!

回答

1

您需要从THE_REQUEST变量中捕获此值才能够捕获?也。在root.htaccess中使用此规则:

RewriteEngine On 

RewriteCond %{THE_REQUEST} \s/+posts/(\S+) [NC] 
RewriteRule^index.php?title=%1 [L,QSA] 
+0

非常感谢。但现在的网址是感觉到/出现在最后我的意思是:example/posts/how + are + you?/ work and example.com/posts/how+are+you?不工作 – 2014-10-17 22:19:21

+0

我认为'[B]'也应该在这里传递:https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_b – hjpotter92 2014-10-17 23:57:47

+0

其实我已经用'B'测试过,没有'B '在发布这个答案之前。用'B'标志'$ _GET ['title']'变成'how + do + man + live'/'而没有'B'它来了'人怎么活着?/' – anubhava 2014-10-18 06:47:21