内部服务器错误 - 多个深度URL字符串

时间:2012-09-11 16:14:21

标签: .htaccess mod-rewrite

我目前正在为我的网站使用此.htaccess文件,

RewriteEngine On
RewriteRule ^u/([^/]+)/[^/]+)/[^/]+)/?$ /index.php?username=$1&content=$2&type=$3 [L,QSA]
RewriteRule ^u/([^/]+)/[^/]+)/?$ /index.php?username=$1&content=$2 [L,QSA]
RewriteRule ^u/([^/]+)/?$ /index.php?username=$1 [L,QSA]

但我收到了错误

  

服务器遇到内部错误或配置错误,无法完成您的请求。

我想要实现的目标是打开这个网址

http://www.site.com/users/index.php?username=$1&content=$2&type=$3

http://www.site.com/users/username/followers/newest

1 个答案:

答案 0 :(得分:0)

您缺少一些开括号:

RewriteRule ^u/([^/]+)/[^/]+)/[^/]+)/?$ /index.php?username=$1&content=$2&type=$3 [L,QSA]
RewriteRule ^u/([^/]+)/[^/]+)/?$ /index.php?username=$1&content=$2 [L,QSA]
RewriteRule ^u/([^/]+)/?$ /index.php?username=$1 [L,QSA]

需要:

# missing "(" here ----v and --v
RewriteRule ^u/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?username=$1&content=$2&type=$3 [L,QSA]
RewriteRule ^u/([^/]+)/([^/]+)/?$ /index.php?username=$1&content=$2 [L,QSA]
RewriteRule ^u/([^/]+)/?$ /index.php?username=$1 [L,QSA]

另外,如果您希望自己的网址看起来像http://www.site.com/users/username/followers/newest,请将开头的^u/更改为^users/