I've got a site with SSL (Certbot) enabled and so I've setup my 301 redirects in the /etc/apache2/sites-available/example.com-le-ssl.conf
file. I did it this way since the non-ssl virtual host (:80) redirects everything to :443 as far as I understand it.
Some of the redirects work, but if the URL fragment is the same (except moved into a parent URL slug) then I get a redirect loop. Also, blog posts with a GET
parameter aren't being picked up at all.
Like so:
# This works
Redirect 301 /foobar https://www.example.com/slug/foo-bar/
# This loops
Redirect 301 /foo-bar https://www.example.com/slug/foo-bar/
# This doesn't seem to redirect at all
Redirect 301 /article.cfm?blogid=9 https://www.example.com/blog/pretty-name/
I can guess that the looping one redirects properly the first time, but then also sees /foo-bar
at the end of the new URL and attempts another redirect. I end up with a URL in the browser bar that looks like:
https://www.example.com/slug/foo-bar///////
Until I get an error from Chrome about redirect loops.
So, I thought that the leading /
right after Redirect 301
only picked up the URL fragment starting from immediately after the base of the FQDN?
And is there any reason why a 301 with a GET
parameter (e.g. /article.cfm?blogid=9
) doesn't work either?
I Googled around but so much of what I found is just about moving non-www to www or non-ssl to ssl. I also find the documentation a bit obtuse.
EDIT: These directives are directly inside of the <VirtualHost>
and not inside of a <Directory>
block. From the non-ssl config, 3 different domains are being redirected to the new, canonical domain. Rather than having a non-canonical domain redirect to https and then to the canonical, I changed the RewriteRule
to direct all to the https version of the canonical. I also removed the trailing slashes from the 301 redirect lines in the ssl config file.
<Directory>
wrapper? What other directives do you have? Are.htaccess
enabled? Any.htaccess
files? What are the URLs you are requesting? Do these map to physical files (I assume not)?