SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2007
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    (Easy) What is htaccess for Rewrite dynamics urls oldname-id.html to newname-id.html

    I want to redirect Rewrite dynamics oldname-id.html to newname-id.html , because the file name is changed


    The file name is changed
    the id is dynamic numbers



    for example

    old urls
    Code:
    http://www.domain.com/country-origin-Irish-page-1.html
    http://www.domain.com/country-origin-Irish-page-2.html
    http://www.domain.com/country-origin-Irish-page-3.html
    http://www.domain.com/country-origin-Irish-page-4.html
    and so on

    to new urls
    Code:
    http://www.domain/country-origin-Irlandia,_Ireland,_Irish-page-1.html
    http://www.domain/country-origin-Irlandia,_Ireland,_Irish-page-2.html
    http://www.domain/country-origin-Irlandia,_Ireland,_Irish-page-3.html
    http://www.domain/country-origin-Irlandia,_Ireland,_Irish-page-4.html
    and so on




    Please help guys what is the right htaccess for this
    Make the world better

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,087
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Normally I don't deal out freebies, but this one is quite easy.
    Here ya go:

    Code:
    RewriteEngine On
    RewriteRule ^country-origin-Irish-page-(\d+)\.html$ /country-origin-Irlandia,_Ireland,_Irish-page-$1.html
    If you are on Apache 1.x change ^ to ^/
    If you're not sure whether you are Apache 1.x or 2.x change ^ to ^/?

    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,656
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    ScallioXTX,

    I already gave him that - in the tutorial linked in my signature AND which is in the sticky posts. Why, oh, why do we have to repeat EVERYTHING when someone won't take the time to look. I hate spoonfeeding!

    In addition, if basketmen only has the four URLs to change, mod_alias' Redirect would be much faster (but only because it's part of Apache's core).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  4. #4
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,087
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by dklynn View Post
    In addition, if basketmen only has the four URLs to change, mod_alias' Redirect would be much faster (but only because it's part of Apache's core).
    Yes I know, but the "and so on" he typed suggested to me there are lots of URL's, in which case I reckoned mod_rewrite would be faster
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •