Search

I'm trying to add some redirects to my Symphony install so links from a few of my old pages on my site will permanently redirect to the new URLs.

I have this in the .htaccess file:

Redirect 301 /2007/04/30/more-psp-hackery-ripping-ps1-games-in-osx/ http://www.joshnichols.com/blog/entry/more-psp-hackery-ripping-ps1-games-in-osx/

When I try to go to the old address it redirects, but the URL gets extra code added to the end and Symphony gives an error 404

This link:

http://www.joshnichols.com/2007/04/30/more-psp-hackery-ripping-ps1-games-in-osx/

Turns into this:

 http://www.joshnichols.com/blog/entry/more-psp-hackery-ripping-ps1-games-in-osx/?page=2007/04/30/more-psp-hackery-ripping-ps1-games-in-osx

The same thing happens with regular .htaccess redirects. I'm guessing Symphony's .htaccess code is doing something.

Anyone have experience with 301 redirects in Symphony that could help me solve this? I hope there's a fix that doesn't require editing Symphony's default .htaccess code.

Thanks!

Did you place this redirect before or after Symphony's rules?

I tried it in both spots with the same results.

I think I figured it out. Right after this bit of code in the Symphony-generated .htaccess,

### Symphony 2.0 - Do not edit ###

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /

put in your redirects like this:

 ### Redirects from old site
 RewriteRule ^2007/04/30/more-psp-hackery-ripping-ps1-games-in-osx/$ http://www.joshnichols.com/blog/entry/more-psp-hackery-ripping-ps1-games-in-osx/ [R=301,L]

The bit between the ^ and the $ is the old URL and then the second part, after a space, is the new URL. [R=301,L] means it's a 301 redirect and to end the RewriteRule. To add more redirects, just add a new RewriteRule on the next line.

Oh, and if you have a URL to redirect that uses an extension, don't forget to escape the . with a \.

Like this:

RewriteRule ^2007/04/30/more-psp-hackery-ripping-ps1-games-in-osx/index\.php$ http://www.joshnichols.com/blog/entry/more-psp-hackery-ripping-ps1-games-in-osx/ [R=301,L]

Glad you figured out. Thanks for posting the follow-up solution!

I've done this in Symphony 2.3.3 but I keep getting it added a weird ?symphony-page query string.

Here is my .htaccess file:

https://gist.github.com/290cb78bab4f5183d720

The string that gets added when going to a redirected page like:

http://songsforsaplings.com/missions/ukraine_info.php/

is this:

http://songsforsaplings.com/missions/ukrainian/?symphony-page=missions/ukraine_info.php/

Any idea how to solve this?

The symphony-page querystring is how Symphony secretly deals with pages and routing to resources.

A point to note here guys is that Redirect is an apache directive that isn't dependent on mod_rewrite so adding those rules inside the <IfModule> clause is silly. Redirect directives work best when placed at the beginning of the .htaccess file, before any other directives to save on overhead of Apache processing.

The best place (I think) to process these rules would be just before the frontend rewrites for Symphony, as you're redirecting into Symphony.

RewriteRule  churches.php  partnership/  [R=301, L]
RewriteRule  language_info.php/?  missions/  [R=301, L]
RewriteRule  missions/french_info.php  missions/french/  [R=301, L]
RewriteRule  missions/chichewa_info.php  missions/chichewa/  [R=301, L]
RewriteRule  missions/poland_info.php  missions/polish/  [R=301, L]
RewriteRule  missions/ukraine_info.php/?  missions/ukrainian/  [R=301, L]
RewriteRule  missions/spanish_info.php  missions/spanish/  [R=301, L]

### FRONTEND REWRITE - Will ignore files and folders
...

I can't promise this will work, as htaccess is black magic sometimes, but it's along the right track.

One questions I have though is:

  1. Do you want the URL to remain with .php at the end or physically redirect to the new URL?

Just thinking some more, you could easily move your Redirect directives to the beginning of the file as I said, but use a Redirect 301 directive, and it should solve the issue.

Ok, right, here is the answer...

Using my first suggestion of changing them to RewriteRules, use the following example

RewriteRule churches.php partnership/ [R=301,L]

Sorry for necropost, but I am having a similiar problem redirecting a site.

No matter where I put the redirect code, /?symphony-page=about-us/ is appended to the url. The rest of the redirect works, but of course this get variable breaks the whole redirect.

.htaccess code below...

RewriteEngine on
RewriteBase /

### SECURITY - Protect crucial files
RewriteRule ^manifest/(.*)$ - [F]
RewriteRule ^workspace/(pages|utilities)/(.*).xsl$ - [F]
RewriteRule ^(.*).sql$ - [F]
RewriteRule (^|/). - [F]

### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"
RewriteCond %{REQUEST_FILENAME} favicon.ico [NC]
RewriteRule .* - [S=14]

### IMAGE RULES
RewriteRule ^image/(.+.(jpg|gif|jpeg|png|bmp))$ extensions/jit_image_manipulation/lib/image.php?param=$1 [B,L,NC]

### CHECK FOR TRAILING SLASH - Will ignore files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [L,R=301]

### URL Correction
RewriteRule ^(symphony/)?index.php(/.*/?) $1$2 [NC]

### ADMIN REWRITE
RewriteRule ^symphony/?$ index.php?mode=administration&%{QUERY_STRING} [NC,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^symphony(/(.*/?))?$ index.php?symphony-page=$1&mode=administration&%{QUERY_STRING}   [NC,L]

### ATTEMPT AT REDIRECTION
RewriteRule ^/about-us /about [R=301,L]

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

#

After all the difficulties with redirection, and the fact that our rules are pretty intense, I would probably recommend using one of the Routing extensions. There's the Symphonists one, and Jens' one too, both available on symphonyextensions.com

Please note that if you want to have custom rules in the .htaccess file, you must put them above the Symphony block, because the latter may be changed by Symphony (e.g. during an update)!

Writing proper rewrite or redirect rules is not easy, but it has nothing to do with Symphony. So we can't really help everybody who starts to write such rules. Using a routing extension (as proposed by @designermonkey) may indeed solve your issues faster.

and the fact that our rules are pretty intense

Well, rewrite rules are always special stuff, and I don't think that Symphony makes it extraordinarily hard. It's simply s.th. that takes some time to be mastered.

^ lots of conflicting information across a few threads on here regarding the position of custom htaccess code.

I stick it at the top - nothing happens. I stick it in the middle before the frontend rewrites - nothing happens. I stick it at the end of the block - nothing happens.

@ollybradshaw: it's not the prettiest solution, but if you append a ? at the end of your resulting URL, rewrite rule will essentially drop all the original get parameters.

RewriteRule about-us/ company/about-us/? [R=301,L]

@ollybradshaw, in case you're using redirects and not just rewrites, browsers are allowed to cache redirects, so make sure that you're not seeing the results of previous versions of your .htaccess file. Open up a new private browser window or something similar to test after each update.

Cool - thanks guys. I will check out Davids solution first to make sure everything is ok. I don't know if Allens solution will have any negative impact on SEO though...

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details