mod_rewrite internal server error / 404 - change of URL

Discussion in 'Apache' started by sakredicuman, Nov 27, 2012.

  1. #1
    Before I start banging my head on the wall, I'd like to kindly ask for some support. :) I'm quite new to this ...

    For several days now I've tried to make my redirects / RewriteRules work, but I'm only jumping back and forth between 500 internal server error and 404s page not found. :-( I've worked my way through many threads and guides, learnt a lot about mod_rewrite and improved my knowledge about regular expressions (amazing how much information is available online). I do sense the solution is right in front of me, but still in the dark and laughing at me. So far it hasn't jumped on me. Please give it a kick or whatsoever!

    The name of the WordPress "slug" for the page has changed from mysite.co.uk/a-b to /a-b-e to /a-b-d-e to /a-b-c-d-e.
    There are several subpages attached to it, so I thought RewriteRule might work best.

    Content of .htaccess:

    RewriteEngine On
    RewriteBase /
    # This actually works
    RewriteCond %{HTTP_HOST} ^www\.mysite\.co\.uk$ [NC]
    RewriteRule ^(.*)$ http://mysite.co.uk/$1 [R=301,L]
    # And now it gets messy
    RewriteRule ^a-b(/.*)?$ http://mysite.co.uk/a-b-c-d-e$1 [R=301, L]
    RewriteRule ^a-b-e(/.*)?$ http://mysite.co.uk/a-b-c-d-e$1 [R=301, L]
    RewriteRule ^a-b-d-e(/.*)?$ http://mysite.co.uk/a-b-c-d-e$1 [R=301, L]

    -> This throws the 500 at my screen

    Even when I try to do it all with Redirects, it doesn't work.

    # Again, this works
    Redirect 301 /a-b http://mysite.co.uk/a-b-c-d-e
    # But when adding the following line, I get a 404 for it, but not for the version of /a-b - Why?
    Redirect 301 /a-b-e http://mysite.co.uk/a-b-c-d-e

    Could someone please point me in the right direction? Thanks!
     
    sakredicuman, Nov 27, 2012 IP