5

I dont't currently need a home page on the personal site I'm working on but I want to be able to keep the option open in the future. I currently have

{% redirect 'portfolio' %}

as the only code on the index page but Craft seems to take a while before it redirects to the portfolio page.

I tried a rewrite rule and while it worked it doesn't change the URL and I didn't see much difference in the time it took to load the page. In fact, it seemed to take longer on my local machine running MAMP Pro 3 then the redirect tag did.

I also looked into Reroute plug-in by Trevor Davis which seemed to work about as well as the redirect tag, maybe slightly better.

Any thoughts as to which is a better approach and why a simple index page with a redirect tag on it would take so long to process?

1 Answer 1

4

.htaccess should always be faster because it doesn't involve PHP or Craft at all.

But on top of that the {% redirect %} tag should be pretty darn quick.

Upon hitting it, Craft immediately calls Yii's CHttpRequest->redirect(), which sets the redirect header and terminates the current request.

1
  • Note: if you get in the situation of requires many redirects this question may be useful. I only mention this because I stumbled on this page while looking for "efficient apache redirects".
    – AnnanFay
    Commented Feb 7, 2018 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.