php - My 301 Redirect redirects without slash after the .dot

204

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!

643

Answer

Solution:

Try this

Redirect 301 /verhuur-grondverzet-minigraver-15ton-verhuur/ https://bpmverhuur.nl/verhuur-grondverzet-minigraver-15ton-verhuur/
921

Answer

Solution:

TheURL-path argument forRedirect is treated as a prefix.

Redirect 301 / https://www.bpmverhuur.nl

So this affects all requests that start with/.

https://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirect:

Then any request beginning with URL-path will return a redirect request to the client at the location of the target URL. Additional path information beyond the matched URL-path will be appended to the target URL.

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.

People are also looking for solutions to the problem: php - Updated MAMP on Windows 7 and started getting error when trying Laravel migrate - PDOException::("could not find driver")

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.