How to re-direct blog article URLs?

75 views Asked by At

I am trying to redirect a bunch of old blog article URLs using the .htaccess file:

RedirectMatch ^/index\.php/global/article/(.*)$ http://www.mywebsite.com/blog/article/$1

This doesn't really work, however, because my CMS seems to get confused by the index.php bit and keeps adding ?symphony-page= to all the URLs.

It's probably this part that is responsible:

### FRONTEND REWRITE - Will ignore files and folders
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*\/?)$ index.php?symphony-page=$1&%{QUERY_STRING}    [L]

Can anybody help?

2

There are 2 answers

2
Mike Rockétt On BEST ANSWER

Please try the following (comments included to explain):

RewriteEngine On

# First, redirect the old URIs to the new ones via a 301 redirect.
# This will allow the CMS to take over using the rules that follow.
RewriteRule ^index.php/global/article/(.+)$ /blog/article/$1 [L,R=301]

# Frontend Rewrites - for the CMS
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*\/?)$ index.php?symphony-page=$1&%{QUERY_STRING} [L]
5
Mi-Creativity On

Try this:

#-- Input URL >>  http://www.mywebsite.com/index.php/global/article/abc


### FRONTEND REWRITE - Will ignore files and folders
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*\/?)$ index.php?symphony-page=$1&%{QUERY_STRING}

RewriteCond %{REQUEST_URI} ^/index\.php/global/article/(.*)$
RewriteRule ^.*$ blog/article/%1  [R=301, L]


#--Output URL >>  http://www.mywebsite.com/blog/article/abc

I've tested the above with this htaccess.madewithlove and it seems like it will work just fine, hopefully it will work for you too

Screenshot:

enter image description here