WordPress Redirect

Please help me understand why my rules highlighted in red don’t work. :frowning:

URL
www . markrequenaphotography . ca/wedding-photography/?serv=Professional%20Wedding%20Photography&loc=Kent%20Bridge

.htaccess


RewriteEngine On
RewriteBase /
[COLOR=#FF0000]RewriteCond %{QUERY_STRING} ^serv=(.*?)&loc=([^/]*)$ [NC]
RewriteRule (.*) http://www.markrequenaphotography.ca/%1/%2/? [R=301]
[/COLOR]
RewriteCond %{HTTP_HOST} ^markrequena\\.ca$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\\.markrequena\\.ca$ [NC,OR]
RewriteCond %{HTTP_HOST} ^markrequenaphotography\\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^markrequena\\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\\.markrequena\\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^requena\\.co\\.uk$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\\.requena\\.co\\.uk$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\\.markrequenaphotography\\.com$ [NC]
RewriteRule (.*) http://www.markrequenaphotography.ca [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Output
www . markrequenaphotography . ca/wedding-photography/?serv=Professional%20Wedding%20Photography&loc=Kent%20Bridge

From my reading of what you’ve shown, the resultant URI should have been Professional%20Wedding%20Photography/loc=Kent%20Bridge which should not exist as a file, thus, /index.phpl

Regards,

DK

@w1nk5

Notice the “last” flag, highlighted in red.

RewriteRule (.*) http://www.markrequenaphotography.ca/%1/%2/? [R=301,L]

Without that, all the other rewrite rules are still applied, in particular the last rewrite rule, which rewrites to index.php.

w1nk5,

The Last flag simply tells Apache to execute the redirection and start over with mod_rewrite processing with the new {REQUEST_URI} string which will then should bypass the first two RewriteRule blocks and WP’s greedy code will then redirect the non-file and non-directory requests to index.php. In other words, the Last flag has nothing to do with the end result of index.php because mod_rewrite will continue its processing until there are no redirections.

Regards,

DK