我的.htaccess
文件存在问题。我有一个像http://example.com/auction/category.php?lvl_1=texnologia
这样的网址。我使用.htaccess
文件中的代码:
RewriteEngine On
RewriteRule ^([^/]*)$ /auction/category.php?lvl_1=$1 [L]
它完美无缺:http://example.com/texnologia
http://example.com/auction/category.php?lvl_1=texnologia&lvl_2=gaming
转到http://example.com/texnologia/gaming
。http://example.com/auction/category.php?lvl_1=texnologia&lvl_2=gaming&lvl_3=konsoles
去
http://example.com/texnologia/gaming/konsoles
。根据我之前的代码,我提出:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /auction/category.php?lvl_1=$1&lvl_2=$2 [L]
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /auction/category.php?lvl_1=$1&lvl_2=$2&lvl_3=$3 [L]
但是,我收到500错误。
答案 0 :(得分:0)
这样的事情应该做:
(您需要确保/auction/category.php
与任何规则不匹配,否则您将最终使用重定向循环)
RewriteEngine On
RewriteRule ^([^/]*)$ /auction/category.php?lvl_1=$1 [L]
RewriteCond %{REQUEST_URI} !/auction/category\.php
RewriteRule ^([^/]*)/([^/]*)$ /auction/category.php?lvl_1=$1&lvl_2=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /auction/category.php?lvl_1=$1&lvl_2=$2&lvl_3=$3 [L]