php - My 301 Redirect redirects without slash after the .dot
We just copied our site to a new url. To preserve the links we're trying to 301 redirect the old urls to the new website.
My htacces code looks like this
Redirect 301 / https://www.bpmverhuur.nl
Redirect 301 /verhuur-grondverzet-minigraver-15ton-verhuur/ https://bpmverhuur.nl/verhuur-grondverzet-minigraver-15ton-verhuur/
When navigating to the initial link, the browser redirects me to:
https://www.bpmverhuur.nlverhuur-grondverzet-minigraver-15ton-verhuur This misses the slash after the .nl How could I fix this?
Thanks in advance!
Answer
Solution:
Try this
Answer
Solution:
The
URL-path
argument forRedirect
is treated as a prefix.So this affects all requests that start with
/
.https://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirect:
This means, if
/foobar
gets requested, the additional path information beyond the matched URL-path will be justfoobar
. And you specifiedhttps://www.bpmverhuur.nl
as the base this should be appended to, so you end up withhttps://www.bpmverhuur.nlfoobar
. So you should add a trailing slash to this base, to fix that issue.And then switch the order of your directives - so that
/verhuur-grondverzet-minigraver-15ton-verhuur/
gets taken care of first. You need to go most specific first, less specific later.