用htaccess重写带有问号的规则

时间:2015-07-26 21:14:00

标签: apache .htaccess mod-rewrite

这是我的htaccess

<IfModule mod_xsendfile.c>
<Files *.php>
XSendFile On
SetEnv MOD_X_SENDFILE_ENABLED 1
</Files>
</IfModule>
RewriteEngine On
#RewriteRule . - [E=no-gzip:1]
RewriteBase /

# forward app requests
RewriteRule ^app/(.*) plugins/webdav/site/control/$1 [QSA,L]

# route everything via index.php if it doesn't exist as a file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?_page_url=$1 [QSA]

我想要做的是在网址中添加?v = 例 mysite.com/?v=filename

我试过这个

RewriteCond %{QUERY_STRING}     ^v=(.*)$    [NC]
RewriteRule ^$      index.php?_page_url=$1     [NC,L]

1 个答案:

答案 0 :(得分:0)

您的反向引用不正确。要从RewriteCond反向引用匹配模式,您需要使用%符号。 $是反向引用RewriteRule匹配模式

所以你的规则应该是这样的:

RewriteCond %{QUERY_STRING}     ^v=(.*)$    [NC]
RewriteRule ^$      index.php?_page_url=%1     [NC,L]

HTH