简体   繁体   中英

.htaccess rewrite rule condition doesn't work

I'm trying to do a rewrite rule but is not possible to me to find the correct expression. I've been searching in different kind of regular expression validators and they say that the expression works.

My .htaccess looks as follows:

Options +FollowSymlinks -MultiViews -Indexes
DirectoryIndex index.php index.html index.htm
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php(.+)=([a-zA-Z]+)&([a-z]+)=([a-zA-Z]+)&([a-z]+)=([a-zA-Z]+)&([a-z]+)=(.*)$ /$3+$5+$7 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

The example URI is: http://www.example.com/index.php?r=site/action&param1=value1 .

You can't match against the query string in a rewrite rule, you need to either use the %{QUERY_STRING} or %{THE_REQUEST} variables.

Although it's entirely unclear what you're trying to do, try something like this:

Options +FollowSymlinks -MultiViews -Indexes
DirectoryIndex index.php index.html index.htm
RewriteEngine on
RewriteBase /

RewriteCond %{THE_REQUEST} \ /+index\.php\?(.+)=([a-zA-Z]+)&([a-z]+)=([a-zA-Z]+)&([a-z]+)=([a-zA-Z]+)&([a-z]+)=(.*)
RewriteRule ^ /%3+%5+%7 [L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM