htaccess代码没有按预期工作

时间:2013-06-19 16:56:47

标签: php .htaccess

我在.htaccess文件中写了这个:

RewriteRule   ^dashboard/(.*)/([0-9]+)/([0-9]+)/(.*)$   dashboard.php?view=$1&idteam=$2&idplayer=$3&layout=$4  [L]

我希望它能给我这个:

  

[ “视图”] => string(4)“team”[“idteam”] => string(1)“5”
  [ “idplayer”] => string(1)“1”[“layout”] =>串(10)   “editplayer”

但我得到了这个:

  

array(3){     [ “视图”] =>     string(4)“团队”     [ “idteam”] =>     string(1)“5”     [ “布局”] =>     string(13)“1 / editplayer”   }

这是网址:

  

仪表板/团队/ 5/1 / editplayer

这是我的全部内容:

ErrorDocument 404   /index.php

Options +FollowSymlinks
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^wmisports.com 
RewriteRule (.*)   http://www.wmisports.com/$1  [R=301,L]

#AddType application/x-httpd-php .html .htm


RewriteRule   ^dashboard$ dashboard.php [L]
RewriteRule   ^dashboard/view/newteam/(.*)$     dashboard.php?view=newteam&idcaptain=$1  [L]
RewriteRule   ^dashboard/view/team/(.*)$    dashboard.php?view=team&idteam=$1  [L]
RewriteRule   ^dashboard/team/([0-9]+)/(.*)$    dashboard.php?view=team&idteam=$1&layout=$2  [L]
#RewriteRule   ^dashboard/([^/]+)/([^/]+)/([^/]+)/([^/]+)$      dashboard.php?view=$1&idteam=$2&idplayer=$3&layout=$4  [L]
RewriteRule ^dashboard/([^/]+)/([^/]+)/([^/]+)/([^/]*)/?$ dashboard.php?view=$1&idteam=$2&idplayer=$3&layout=$4 [L]

请大家帮忙了解我的代码有什么问题。感谢

1 个答案:

答案 0 :(得分:1)

尝试用以下代码替换代码:

RewriteRule ^dashboard/([^/]+)/([^/]+)/([^/]+)/([^/]*)/?$ dashboard.php?view=$1&idteam=$2&idplayer=$3&layout=$4 [L]

编辑:这就是你的.htaccess应该是这样的:

ErrorDocument 404   /index.php

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^wmisports\.com$
RewriteRule (.*) http://www.wmisports.com/$1 [R=301,L]

#AddType application/x-httpd-php .html .htm

RewriteRule ^dashboard/([^/]+)/([^/]+)/([^/]+)/([^/]*)/?$ dashboard.php?view=$1&idteam=$2&idplayer=$3&layout=$4 [L]

RewriteRule ^dashboard/team/([0-9]+)/(.*)$ dashboard.php?view=team&idteam=$1&layout=$2 [L]

RewriteRule ^dashboard/view/newteam/(.*)$ dashboard.php?view=newteam&idcaptain=$1 [L]

RewriteRule ^dashboard/view/team/(.*)$ dashboard.php?view=team&idteam=$1 [L]

RewriteRule ^dashboard$ dashboard.php [L]