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.

Dynamic to static url in htaccess

Discussion in 'PHP' started by arp059, Sep 25, 2009.

  1. #1
    I understand php is not the right forum to discuss this, but apache forum has no active users which made me come here.

    Kindly help me with this simple workaround.

    I am working on a small site where I need to convert dynamic url to static one whose variations are as below.

    Dynamic url
    Note that Page 1 does not have the page number attribute in the url and directly it should be taken as 1 by default.

    The static url I want is
    for 1st page it will be
    Thanks a lot for the help in advance :)

    Hope to see quick replies.
     
    arp059, Sep 25, 2009 IP
  2. mehdi

    mehdi Peon

    Messages:
    258
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello,
    Try this:
    
    RewriteEngine on
    
    RewriteRule topic/(.*?)/(.*?)/$ cat.php?catslug=$1&page=$2
    RewriteRule topic/(.*?)/$ cat.php?catslug=$1&page=1
    
    Code (markup):
     
    mehdi, Sep 25, 2009 IP
    newgenservices likes this.
  3. renownedmedia

    renownedmedia Well-Known Member

    Messages:
    65
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    100
    #3
    Just a note, that .htaccess would be placed at the root of your site, but if you wanted to place it in a folder called topic you'd do something like this:

    
    RewriteEngine on
    
    RewriteRule (.*?)/(.*?)/$ cat.php?catslug=$1&page=$2
    RewriteRule (.*?)/$ cat.php?catslug=$1&page=1
    
    Code (markup):
     
    renownedmedia, Sep 29, 2009 IP