1

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

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

我希望它应该给我这个:

["view"]=> string(4) "team" ["idteam"]=> string(1) "5"
["idplayer"]=> string(1) "1" ["layout"]=> string (10) “编辑播放器”

但我得到了这个:

array(3) { ["view"]=> string(4) "team" ["idteam"]=> string(1) "5" ["layout"]=> string(13) "1/editplayer" }

这是网址:

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

这是我的整个 htaccess :

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]

请有人帮助了解我的代码有什么问题。谢谢

4

1 回答 1

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]
于 2013-06-19T17:06:36.460 回答