我有这个.htaccess
代码,用于使用apache重写我的网址:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(archive)/(.*)/([a-z]+)/(.*)/(.*)$ index.php?page=$1&type=$2&action=$3&sort=$4&order=$5&lang=fr [NC,L,QSA]
这工作并重写我的网址:
http://localhost/cms/archive/gallery/list/all/desc
现在我需要添加查询字符串(如果我有分页),如下所示:
http://localhost/cms/archive/gallery/list/all/desc/?pagination=1
但是我看到了这个错误
Warning: require_once(/Applications/XAMPP/xamppfiles/htdocs/cms//modules/gallery/list/archive.php):failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/cms/modules/archive/main.php on line 7
如何解决这个问题?!
答案 0 :(得分:0)
此规则
RewriteRule ^(archive)/(.*)/([a-z]+)/(.*)/(.*)$ test.php?page=$1&type=$2&action=$3&sort=$4&order=$5&lang=fr [NC,L,QSA]
使用print_r($_GET)
Array ( [page] => archive [type] => gallery [action] => list [sort] => all [order] => desc [lang] => fr )
请注意type = gallery和action = list
的值对于此网址
http://localhost/cms/archive/gallery/list/all/desc
但是,输出
Array ( [page] => archive [type] => gallery/list [action] => all [sort] => desc [order] => [lang] => fr [pagination] => 1 )
请注意type = gallery / list和action = all
的值对于此网址
http://localhost/test/archive/gallery/list/all/desc/?pagination=1
现在,我认为有两个修正,要么在规则中添加斜杠,就像这样
RewriteRule ^(archive)/(.*)/([a-z]+)/(.*)/(.*)/$ test.php?page=$1&type=$2&action=$3&sort=$4&order=$5&lang=fr [NC,L,QSA]
或删除URL中的最后一个斜杠,如下所示
http://localhost/cms/archive/gallery/list/all/desc?pagination=1