Can anyone help with .htaccess?

Discussion in 'Web Design and Development' started by msjones, Nov 1, 2012.

  1. macrumors 6502

    msjones

    Joined:
    Oct 18, 2007
    Location:
    Nottinghamshire, UK
    #1
    Hello there,

    I am no web coder, but have been asked to resolve an issue with a .htaccess file. I wondered if anyone here would be willing to help me?

    I need to re-write the following link:

    Code:
    http://www.mydomain.com/blogs/untitled/2009/06/my-blog-title.html
    to this:

    Code:
    http://www.mydomain.com/blogs/blog/my-blog-title/
    More specifically I need a rule to re-write /untitled/2009/06/my-blog-title.html to /blog/my-blog-title/.

    Any help or guidance would be much appreciated.

    Thanks in advance
     
  2. macrumors regular

    Joined:
    Feb 24, 2010
    Location:
    Sydney, Australia
    #2
    Here, try this:

    Code:
    //301 Redirect Entire Directory
    RedirectMatch 301 http://www.mydomain.com/blogs/untitled/2009/06/my-blog-title.html(.*) 
    http://www.mydomain.com/blogs/blog/my-blog-title//$1
     
    Let me know if that helps.

    In future, you can alter .htaccess files with this:

    http://www.htaccessredirect.net/index.php
     
  3. thread starter macrumors 6502

    msjones

    Joined:
    Oct 18, 2007
    Location:
    Nottinghamshire, UK
    #3
    Thanks for that man, really helped. I took it a little further with some regex matching.

    Code:
    RedirectMatch 301 /blogs/[0-9][0-9][0-9][0-9]/[0-9][0-9]/(.).html	http://www.mydomain.com/blogs/blog/$1/
    Your help was much appreciated. As a python coder I never really get into any web stuff.
     
  4. macrumors newbie

    Joined:
    Jul 11, 2013
    #4
    Using this site http://www.htaccessredirect301.com , you can do this easily
     

Share This Page