htaccess工作但内容不加载

时间:2011-03-19 09:00:01

标签: .htaccess mod-rewrite loading

当我使用index.php?id = this-is-an-article时,页面会加载内容,当我使用/ articles / this-is-an-article时,页面加载时没有任何内容,任何想法都是我怎么解决这个问题?

.htaccess:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

# force www. in all requests
RewriteCond %{HTTP_HOST} ^mysite\.net [NC]
RewriteRule ^(.*)$ http://www.mysite.net/$1 [L,R=301]

# enable hiding php extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^(.*)\$ $1.php

RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  
RewriteRule ^page/(\d+)*$ ./index.php?p=$1  

# index.php?id=this-is-an-article => /articles/this-is-an-article 
RewriteRule /articles/(.*)  index.php?id=$1 [NC,L]

提前致谢。

1 个答案:

答案 0 :(得分:0)

摆脱领先的斜线。使用^开始这样的正则表达式也是最好的做法,并以$结尾。

RewriteRule ^articles/(.*)$  index.php?id=$1 [NC,L]