Search code examples
wordpress.htaccessconcrete5concrete

Htaccess redirect loop for Concrete downloads, difficulty level: wordpress also in the mix


I have a WordPress install in my root web folder. It is using the standard WordPress .htaccess file:

# 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

For Reasons I cannot change, there used to be a Concrete5 install in the root. It has been moved to a subfolder called "form".

WordPress and Concrete are happily coexisting, with 1 exception: I need previous Concrete downloads to redirect to the new location. And what I am trying in my .htaccess file is not working:

RedirectMatch 301 /index.php/download_file/force/(.*) /form/index.php/download_file/force/$1

I am trying to move from this:

http://example.com/index.php/download_file/force/623/145/

To this:

http://example.com/form/index.php/download_file/force/623/145/

I am currently getting a redirect loop.


Solution

  • Your rewrite pattern must start with a ^

    RedirectMatch 301 ^/index.php/download_file/force/(.*) /form/index.php/download_file/force/$1
    

    Otherwise the redirect destination also matches the pattern /index.php/download_file/force/(.*) and causes a redirect loop