I'm having an issue on this. Say, I have mypage.com/search/mykey
and i want it to map to mypage.com/search?key=mykey
. This is my .htaccess rule:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^search/(.*)$ /search?key=$1 [L]
# Pass all requests not referring directly to files in the filesystem to
# index.php.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
However, in the logs I can see that it's mapping to mypage.com/search/mykey?key=mykey
.
Edit:
To give more context on what can be the issue, I included the rewrite rule just below the one I wrote. Don't know if they're messing each other.
Thanks in advance for all your help.
You could try using RewriteBase "/"
in that way apache knows that relative files must be within the rewrite base path.
RewriteBase "/"
...
RewriteRule ^search/(.*)$ search?key=$1 [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.