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 Help

Discussion in 'Programming' started by Pudge1, Jan 24, 2015.

  1. #1
    Pudge1, Jan 24, 2015 IP
  2. JEET

    JEET Notable Member

    Messages:
    3,825
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #2
    I think you mean to load data of view.php?show=1234 on /content-1234/

    You can use this code for that:

    
    Options -Indexes +FollowSymLinks
    RewriteEngine on
    
    RewriteRule /content-(.*)/$ view.php?show=$1 [R=301,L] 
    
    Code (markup):
     
    JEET, Jan 24, 2015 IP
    Arick unirow likes this.
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    I'm assuming the OP doesn't want to name everything "/content-" but that ANY link with an ID on the end should redirect (why, I've no idea, it's a stupid system, but hey)
    You would need a regex for checking for a number (however, that might break if there's more than one number in the link)
    Besides, why don't you rather redo the links? Instead of tacking on the ID on the end like that, either look up the ID based on the actual url, or if that's not feasible (say, multiple same-name urls with different IDs), do either a /ID-goes-here/content-title-goes-here or /content-title-goes-here/ID-goes-here?
     
    PoPSiCLe, Jan 25, 2015 IP
    Arick unirow likes this.
  4. Equaite

    Equaite Active Member

    Messages:
    128
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    Digital Goods:
    1
    #4
    I wouldn't recommend directing /title-id, maybe something like post/title-id so you don't interfere with any other URLs.
    
    RewriteEngine On
    RewriteRule ^post/(.*?)-([0-9]+)/?$ viewPage.php?id=$2
    
    Code (markup):
    Simply remove post/ if you want it to work like you originally intended.
     
    Equaite, Jan 25, 2015 IP