I’ve used mod_rewrite rules a lot over the years, which is all the more reason for me not understanding why this will not work:
RewriteRule ^cottage/house/(.*)/(.*)$ /cottage/house/$1?query=$2 [L]
I am using it alongside the following .htaccess file:
RewriteEngine On
Rewritecond %{HTTP_HOST} !^www\.website\.com
RewriteRule (.*) http://www.website.com/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
This code should be making a URL of format /cottage/house/housename/about go to /cottage/house/housename?query=about… Any ideas would be greatly appreciated.
I managed to work out the issue – WordPress has it’s own way of dealing with
mod_rewrite.The code below rewrites the URL internally in a way that WordPress understands:
Hope this helps anyone having similar issues.