【发布时间】:2021-10-12 00:01:14
【问题描述】:
我有以下.htaccess 规则:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} page=(.*)
RewriteRule ^(.)([^/])([^/])[^/]*/$ /htcache/videos/$1/$2/$3/$0%{QUERY_STRING}.html? [L]
RewriteRule ^$ /htcache/index.html [L]
RewriteRule ^(.)([^/])([^/])[^/]*\.html$ /htcache/video/$1/$2/$3/$0 [L]
RewriteRule ^(.)([^/])([^/])[^/]*\/$ /htcache/videos/$1/$2/$3/$0\index.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
在此规则中,如果请求的 url 包含查询字符串并且文件在 htcache 文件夹中不存在,则重写规则起作用但查询字符串不执行
请求例如https://www.mywebsite.com/fun-videos/?page=2
如果文件存在/htcache/videos/f/u/n/fun-videos/page=2.html“找到文件”
但如果文件不存在,则页面/index.php 将在没有查询字符串的情况下执行。
一些想法???
【问题讨论】:
-
尝试在您的规则中使用
QSA标志。 QSA 代表Query String Append。
标签: apache .htaccess mod-rewrite