Jump to:

23380 Posts in 18311 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Problem with redirects of old URLs

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1414 Views
  • Sophie
    Avatar
    Community Member
    33 Posts

    Problem with redirects of old URLs Link to this post

    I've been following the various suggestions for rewrites in the htaccess file. I want to direct old page to specific pages on my site. This is my htacces file. Can anyone advise me on what I'm doing wrong? These still direct me to "Page Cannot Be Found" just the way they did before I added the rewrite rule. This site is running 2.2.3.

    Thank you!

    RewriteEngine On
    RewriteRule ^captainslog$ - [L]
    RewriteRule ^captainslog/.* - [L]
    RewriteBase /

    RewriteCond %{REQUEST_URI} !(^$)|(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$

    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]

    RewriteRule index.html/ http://www.mysite.com/home/ [R=301,L]
    RewriteRule links.html/ http://www.mysite.com/links/ [R=301,L]

  • socks
    Avatar
    Community Member
    190 Posts

    Re: Problem with redirects of old URLs Link to this post

    This is the syntax that I used:

    RewriteRule ^links\.html$ /links/ [R=301,NC,L]
    RewriteRule ^index\.html$ /home/ [R=301,NC,L]

  • Sophie
    Avatar
    Community Member
    33 Posts

    Re: Problem with redirects of old URLs Link to this post

    socks,

    I tried your syntax and this did not work either. Thanks for the suggestion!

    Does anyone else have any other thoughts?

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Problem with redirects of old URLs Link to this post

    The syntax proposed by socks looks good to me. You just have to place your custom rewrite rules before the SilverStripe rules, since the SilverStripe rules will match all urls and further rules won't be processed.

    A good place to put your custom rules is directly after the RewriteBase line.

  • Sophie
    Avatar
    Community Member
    33 Posts

    Re: Problem with redirects of old URLs Link to this post

    Bingo! Thank you, banal!

  • Bambii7
    Avatar
    Community Member
    254 Posts

    Re: Problem with redirects of old URLs Link to this post

    Brilliant! real life saver here. I had my 40 or so 301 redirect in my .htaccess, went live with the new site. And I had a little panic attack. 301 didn't work but your rewrite rules rulz

  • Mrfixer
    Avatar
    Community Member
    49 Posts

    Re: Problem with redirects of old URLs Link to this post

    +1, tried a few rewrite configs and could not get nothing to work (or it would work and append the old url), got panicky (well the client was with me at the time.. eek ..)

    did a minutes searching and frantic re-writing while he made us a coffee, when he returned all was good..

    many thanks @socks

    1414 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.