Mod rewrite directory to .html help

Discussion in 'Apache' started by leeds1, Mar 20, 2008.

  1. #1
    Hi

    I have set up a Wordpress blog where I have posts like:

    mysite.com/directory/thepost/ and now want this to read
    mysite.com/directory/thepost.html

    How can I achieve this with my .htaccess file ?

    the /directory/ is the cat name so there are many of these so this needs to be a wildcard

    Additionally, wordpress has set up all the /directory/ as /category/directory/ so I'd like to redirect /category/directory/ to just /directory/

    Does that make sense ?

    thanks in advance for any help
     
    leeds1, Mar 20, 2008 IP
  2. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It's not in the .htaccess rather in the permalinks section under Options. Where it says choose permalinks format click on the custom field and put in /%category%/%postname%.html
     
    maiahost, Mar 20, 2008 IP
  3. leeds1

    leeds1 Peon

    Messages:
    585
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sure - I can change that in WP - but then all inbound links will produce a 404 so I need to mod rewrite as well
     
    leeds1, Mar 20, 2008 IP
  4. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
  5. leeds1

    leeds1 Peon

    Messages:
    585
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi - that would seem to be the solution...

    but I followed everything and still got a 404 on my old structure (although the new one worked)

    I have a writeable .htaccess

    So I guess I still need the mod rules

    Anyone ?
     
    leeds1, Mar 20, 2008 IP
  6. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Last try :)
    RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/$ /$1/$2.html [R=301,L]
     
    maiahost, Mar 20, 2008 IP