ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Redirect problem with template groups

June 15, 2010 10:45am

Subscribe [2]
  • #1 / Jun 15, 2010 10:45am

    My htaccess file looks like this:

    RewriteEngine on
    Redirect 301 /soa/category/seds/ <a href="http://www.scottish-orienteering.org/seds/">http://www.scottish-orienteering.org/seds/</a>
    RewriteCond $1 ^(seds|soa|P[0-9]{2,8}) [NC]
    RewriteRule ^(.*)$ index.php?/$1 [L]

    This then generates a url of http://www.scottish-orienteering.org/seds/?/soa/category/seds/
    that does work and show the correct page but looks bad.

    seds is a template group and a category.

    I have a few similar redirects that have the same problem with adding the query string to the end of the url, but only when there is a template group included in the source for redirection. The following works fine without adding the query string:

    Redirect 301 /contacts <a href="http://www.scottish-orienteering.org/soa/contacts">http://www.scottish-orienteering.org/soa/contacts</a>

    where soa is the template group and contacts is a template in that group.
    So I’m guessing that the problem is to do with a template group listed in the RewriteCond also being part of the Redirect request.

    I’ve tried putting the Redirect before and after the Rewrite to remove the index.php and it makes no difference.
    I’ve searched all my htaccess resources and the EE forums but can’t find a similar issue.

  • #2 / Jun 15, 2010 11:48am

    Focus Lab Dev Team

    1129 posts

    Try changing the Redirect to a RewriteRule

    RewriteEngine on
    
    RewriteRule ^soa/category/seds/ /seds/ [L,R=301]
    
    RewriteCond $1 ^(seds|soa|P[0-9]{2,8}) [NC]
    RewriteRule ^(.*)$ index.php?/$1 [L]
  • #3 / Jun 15, 2010 12:58pm

    Thanks Eric
    That fixed it.

    I’m never sure when to use Redirect or RewriteRule, and I thought I had tried every combination, but I always used the full url to the new page including the http etc.
    I also thought you needed to add $ to end the string you started with the^.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases