1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

.htaccess - how do I remove the same word from the end of a url?

Discussion in 'Apache' started by vwdforum, Mar 18, 2013.

  1. #1
    Hello

    I've modified my old website, and now need to remove the phrase "cheap-products"

    Some example url's

    randomdomain.com/product-1000-cheap-products/
    randomdomain.com/product-1001-cheap-products/
    randomdomain.com/product-1002-cheap-products/

    How do I make it so it will forward (seo wise) to the following

    randomdomain.com/product-1000/
    randomdomain.com/product-1001/
    randomdomain.com/product-1002/

    Thanks in anticipation!Q
    vwdforum, Mar 18, 2013 IP
  2. humtuma

    humtuma Well-Known Member

    Messages:
    1,148
    Likes Received:
    21
    Best Answers:
    3
    Trophy Points:
    165
    #2
    Just redirect the url (301) i.e best. There are some other method also. But some features stopped working, like in SMF, WordPress etc
    Last edited: Mar 18, 2013
    humtuma, Mar 18, 2013 IP
  3. Garkoni

    Garkoni Active Member

    Messages:
    213
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Hi,
    Your .htaccess file:

    Code (Text):
    1. RewriteEngine on
    2. RewriteBase /
    3. RewriteRule ^/product-([0-9]+)-([-a-zA-Z]+)/$ /product-$1/
    Please test and let me know if it doesn't work.
    Garkoni, Mar 19, 2013 IP
  4. RoseHosting

    RoseHosting Active Member

    Messages:
    150
    Likes Received:
    7
    Best Answers:
    6
    Trophy Points:
    88
    #4
    Add the following lines to your .htaccess file:

    RewriteEngine On
    RewriteRule ^(.*)-cheap-products(.*)$ /$1 [R=301,L]
    RoseHosting, Mar 19, 2013 IP
  5. Garkoni

    Garkoni Active Member

    Messages:
    213
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Great solution! Better than mine!
    Garkoni, Mar 20, 2013 IP