WordPress.org

Ready to get started?Download WordPress

Forums

Redirect permalink only with mod rewrite. (6 posts)

  1. kurai
    Member
    Posted 6 years ago #

    Hi!
    I moved my wordpress weblog to a subdomain, leaving in the main domain an aggregator page. Now I would like to redirect permalink requests to the new domain, leaving the access to the main page intact.
    Basically, what I'm trying to do is to redirect all the addresses of this kind:

    http://kurai.eu//%post_id%/%postname%/
    to
    http://insertcoin.kurai.eu//%post_id%/%postname%/

    leaving access to kurai.eu and all the other standard subdirectory intact.

    I tried this rule:
    RewriteRule ^kurai\.eu/([0-9]+)/$ http://insertcoin.kurai.eu/$1/ [R=301,NC,L]
    but it seems not working. Obviously I've got problems with regular expressions. Can you help me out with this?

    Thank you!

  2. heiseheise
    Member
    Posted 6 years ago #

    Did you ever get this figured out, Kurai? I'm trying to do the exact same thing that you are, except backwards - I'm moving from http://www.heiseheise.com/blog to http://www.heiseheise.com with my blog files and so I have a whole ton of old links just lying around to /blog that now redirect to nothing.

    I'd like to make it so that they'll automatically drop the /blog from the URL and just go to the /?=%number% instead!

    please let me know if you were successful; we can probably reverse engineer it!

  3. Ivovic
    Member
    Posted 6 years ago #

    heiseheise, you'd be better served doing a search/replace on your database, to change those links in your old posts.

  4. wesg
    Member
    Posted 6 years ago #

    Have you figured it out, heiseheise?

    I have here an .htaccess rewrite that moves all requests for http://domain.com/blog to http://domain.com


    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^blog/?(.*) /$1 [R=301,L]
    </IfModule>

    example: a request for http://domain.com/blog/2008/06/hello-world/ will now be directed to http://domain.com/2008/06/hello-world/

  5. scribu
    Member
    Posted 6 years ago #

    @kurai: The problem with your regex is that you're only selecting a series of digits with [0-9]. You need to be selecting all the characters, basically, so the correct expression would be:

    RewriteRule ^kurai\.eu/(.+)/$ http://insertcoin.kurai.eu/$1/ [R=301,NC,L]

  6. Firkraag85
    Member
    Posted 6 years ago #

    wesg, that doesn't work... Because for example with that code we can't acceed to admin panel, or acceed to CSS styles, etc.

    I really need help on this.

Topic Closed

This topic has been closed to new replies.

About this Topic