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.

200+ 301's: EE- or php-parsed .htaccess?

May 06, 2009 9:06am

Subscribe [3]
  • #1 / May 06, 2009 9:06am

    Les McKeown

    133 posts

    Hi Folks -

    I’m moving a site from coldfusion to EE. It has over 200 well ranked pages,and for SEO and general navigation purposes I need to 301 them.

    It would be laborious to produce and check an .htaccess file with 200+ redirects manually (and I assume server speed parsing it would be slow?).

    The url structure of both the old and new sites are ‘mappable’, from:

    http://oldsite.com/public/123.cfm

    to

    http://newsite.com/article/url_title

    ...and I have the ‘oldsite’ page number available as a custom field in newsite. So in my templates, I can ‘translate’ urls from oldsite to newsite by using {exp:weblog entries} and my custom field.

    If I could do this in my .htaccess file, of course, my 301 problem would be solved, but I’m not aware of any way to have EE parse an .htaccess file.

    Any smart ideas? Suggestions? Aspirin?

    Thanks in advance!

  • #2 / May 06, 2009 9:24am

    Ingmar

    29245 posts

    Why would EE have to parse .htaccess? Your server does that, and should automatically froward HTTP requests as appropriate.

  • #3 / May 06, 2009 9:45am

    Les McKeown

    133 posts

    EE doesn’t *have* to, but I would *like* it to…because one line of EE code would replace 200+  manually entered lines…(as per post).

  • #4 / May 06, 2009 9:53am

    Ingmar

    29245 posts

    You should still be able to make it work. What about an URL like

    <a href="http://example.com/index.php/group/template/999">http://example.com/index.php/group/template/999</a>

    where 999 would be the “old” entry_id, now stored in your custom field. Then use a template like

    {exp:weblog:entries ... dynamic="off" search:my_field="={segment_3}" ... }

    Well, something like that, anyway. Makes sense? Now all your have to do is rewrite your old URLs to your new ones, probably using a regular expression in .htaccess.

  • #5 / May 06, 2009 10:09am

    Les McKeown

    133 posts

    This bit is done - I have the templates all working fine:

    You should still be able to make it work. What about an URL like

    <a href="http://example.com/index.php/group/template/999">http://example.com/index.php/group/template/999</a>

    where 999 would be the “old” entry_id, now stored in your custom field. Then use a template like

    {exp:weblog:entries ... dynamic="off" search:my_field="={segment_3}" ... }

     

    This is the bit I’m missing:

    Now all your have to do is rewrite your old URLs to your new ones, probably using a regular expression in .htaccess.

    I think ‘regular expression’ is the pointer I need. (Not that I know how to write such a thing, but I’m sure I’ll find one of those Scriptlance kiddies who do…)

    Thanks, Ingmar.

  • #6 / May 06, 2009 10:20am

    Ingmar

    29245 posts

    Yes, there should be a bit of info or a few tutorials on that out there. Basically, it’s telling the webserver to show http://example.com/index.php/group/template/999 even though http://example.com/old/999.html was requested. And yes, “regular expression” and “url rewriting” certainly are the key words here.

  • #7 / May 06, 2009 10:31am

    Les McKeown

    133 posts

    Thanks for the help, Ingmar - I appreciate it!

  • #8 / Jul 22, 2009 11:46am

    mooo

    168 posts

    I’m trying to do something similar, but my client’s old blog is built on a proprietary system and resides in their blog subdomain, so I’m changing the whole URL. I grabbed the old blog using the Feedgrab plugin, and I was able to get the old URL into a custom field, but now I need to perhaps create an index.php to put in the blog subdomain? How would I use the URL in the custom field to do that?

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

ExpressionEngine News!

#eecms, #events, #releases