21293 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1790 Views |
-
Director::redirect not working on live site

9 March 2010 at 9:43pm Last edited: 9 March 2010 9:45pm
Good Day!
I have the following problem.
I have
Director::redirect('home');
rule in Page.php and on localhost everything works fine. But on live site it just ignores this code. Why could this happen?And one more question: at this moment I'm trying to redirect pages from old site to new pages in SilverStripe. Old site is created with php and xml and it has links like "xslt.php?xml=pagelink" and now I want to redirect it to "pagelink" (like it is named in SilverStripe CMS). Writing in htaccess smth like
RewriteRule ^xslt.php?xml=pagelink$ pagelink
doesn't work. And as I said before Director::redirect doesn't work either. Maybe there is another solution for redirecting pages like "xslt.php?xml=pagelink"?Any help is really appreciated!
Thanks in advance -
Re: Director::redirect not working on live site

10 March 2010 at 5:32pm
Could you post the full code?.
One thing to note - You might want to try including a / after the url. I think it defaults to appending the value to the current URL if it doesn't have a /
Director::redirect('home/');
-
Re: Director::redirect not working on live site

13 March 2010 at 2:29am
So this is the code:
class Page_Controller extends ContentController {
public function init() {
parent::init();
$url = $_SERVER['REQUEST_URI'];
if ($url == '/xslt.php?xml=clients/faq/faq_v&language=ru') {
Director::redirect('faq-v/', 301);
}
}
}I also noticed one strange thing: when I try to use the address (/xslt.php?xml...), 404 page is shown (silverstripe custom 404 page), and site looks like archive site in some way. I do not know how to explain this, but it is surely not the "fresh" version of site. For example, latest news in sidebar section show only 2 items, but at the moment there should be 5 items. And when I go to any other "normal" page, the site is ok and up-to-date.
-
Re: Director::redirect not working on live site

13 March 2010 at 11:25am
One thing to note is that your 404 page is a generated html page in assets (eg assets/error-404.html) these are not generated dynamically but are generated when you publish the page in the cms.
Its probably showing an old version of your theme since the html hasn't been updated. To update it simply republish the Page not found page.
-
Re: Director::redirect not working on live site

15 March 2010 at 8:04am
Thank you Willr for your help!
But what about redirecting? Does anyone have any suggestions? I want to redirect page with url address like "xslt.php?xml=pagelink" to "pagelink". That "xslt.php?xml=pagelink" page does not exist any more. And I really cannot understand how to do that. I tried making .htaccess rules and using Director::redirect with no luck.
-
Re: Director::redirect not working on live site

5 May 2011 at 7:00pm
You would not use anything at the SS level IMHO, Htaccess file would be better. Just a simple rewrite rule:
Perhaps like this (no expert, see google for reference)
RewriteRule .*xslt.php?xml=(.*) $1 [L,R=301]
| 1790 Views | ||
|
Page:
1
|
Go to Top |


