2011-03-16 50 views
0

我有htaccess的不重定向

www.mydomain.com/page_articles 

的链接将指向

www.mydomain.com/page_articles/some_article 

但 “some_article” 摆脱一个PHP文件 “load.php” 渲染所以它看起来像:

www.mydomain.com/page_articles/load.php?page=some_article 

我会在htaccess中插入什么,以便我可以有漂亮的链接?

我目前有:

RewriteEngine On 
RewriteRule ^page_articles$ /page_articles/load.php?page=$1 
RewriteRule ^page_articles/$ page_articles/load.php?page=$1 

感谢

回答

0
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteRule ^page_articles/(.*)$ page_articles/load.php?page=$1 
</IfModule> 

添加括号中的字符串中允许你使用“一些_articles”在页面变量$ 1,这是假设有一个文件在page_articles文件夹中调用load.php

0

沿着这条线应该有效。 (.)捕获/到$ 1之后的任何内容。 。 =任何字符0或更多次。 RewriteCond告诉RewriteRule忽略它,如果匹配以load.php开头(以避免无限循环)。问号表示可能有或没有尾随/。

RewriteCond $1 !^load\.php 
RewriteRule ^page_articles/?(.*) /page_articles/load.php?page=$1 [T=application/x-httpd-php,L,NC]