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.

How to rewrite URL?

Discussion in 'PHP' started by Om ji Kesharwani, Nov 11, 2009.

  1. #1
    Om ji Kesharwani, Nov 11, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    Well its technically possible basically if ur script is like this index.php?username=coolguy we can use modrewrite and make it like www.yourdomain.com/coolguy
     
    Bohra, Nov 11, 2009 IP
  3. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks for your reply, I want to rewrite index.php?username=coolguy to index.php/coolguy and the user should have own price setting right for the contents of the main site through his admin login.
     
    Om ji Kesharwani, Nov 11, 2009 IP
  4. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Om ji Kesharwani, Nov 11, 2009 IP
  5. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #5
    Well is ur script coded ??
     
    Bohra, Nov 11, 2009 IP
  6. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    not now...
    This is my .htacces file content
    # -FrontPage-

    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName inetrevolution.com
    AuthUserFile /home/inetrevo/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/inetrevo/public_html/_vti_pvt/service.grp



    What line to add?
     
    Om ji Kesharwani, Nov 11, 2009 IP
  7. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #7
    Bohra, Nov 11, 2009 IP
  8. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I have created .htaccess file but its not working please tell me whats the error



    # -FrontPage-

    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName 0532.co.in
    AuthUserFile /home/co0532/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/co0532/public_html/_vti_pvt/service.grp

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*)/$ /header-pages.php?page=$id
     
    Om ji Kesharwani, Nov 11, 2009 IP
  9. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    My php file contains..
    <li><? $id=$row2["id"];?><a href="header-pages.php?page=<?echo urlencode($id);?>" ><? echo $row2[pagename]; ?></a></li>
     
    Om ji Kesharwani, Nov 11, 2009 IP
  10. pixmania

    pixmania Peon

    Messages:
    229
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    
    Options +FollowSymLinks
    
    RewriteEngine on
    
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteCond %{REQUEST_FILENAME} !-f
    
    RewriteRule (.[^/]*) /header-pages.php?page=$1 [NC,L]
    
    
    PHP:
     
    pixmania, Nov 11, 2009 IP
  11. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #11
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*)/$ index.php?username=$1

    try this..

    can u tell us ur site it will be easier
     
    Bohra, Nov 11, 2009 IP
  12. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Om ji Kesharwani, Nov 11, 2009 IP
  13. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #13
    Bohra, Nov 11, 2009 IP
  14. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #14
    First of all tell me which .htaccess file i have to edit coz i have htaccess file in folders like..
    public_html
    _vti_cnf
    _vti_txt
    _vti_adm etc...
     
    Om ji Kesharwani, Nov 11, 2009 IP
  15. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #15
    the main one in public_html

    tell us what exactly are u trying to achieve
     
    Bohra, Nov 11, 2009 IP
  16. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #16
    This is my public_html .htaccess code which was already present..


    # -FrontPage-

    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName 0532.co.in
    AuthUserFile /home/co0532/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/co0532/public_html/_vti_pvt/service.grp



    My requirement:
    When user click on contact us, holy city, history etc.. pages of my site http://www.0532.co.in
    the address bar shows url like
    http://0532.co.in/header-pages.php?page=2
    http://0532.co.in/header-pages.php?page=3
    http://0532.co.in/header-pages.php?page=4
    etc..

    I want to rewrite it like
    http://0532.co.in/header-pages/2.html
    http://0532.co.in/header-pages/3.html
    http://0532.co.in/header-pages/4.html
    etc...

    Please post complete .htaccess file or tell me any other server right do i need to perform Mod_rewrite operations?
     
    Om ji Kesharwani, Nov 11, 2009 IP
  17. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #17
    Well ok use this .htaccess file

    
    # -FrontPage-
    
    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
    
    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName 0532.co.in
    AuthUserFile /home/co0532/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/co0532/public_html/_vti_pvt/service.grp
    
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule header-pages/(.*).html$ header-pages.php?page=$1
    
    Code (markup):
    after that u have to change ur script files only and then u will be able to access the pages with the url u want
     
    Bohra, Nov 11, 2009 IP
  18. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Sorry for disturbing u...
    This is my script code where shuld i made change? Coz i used above .htaccess file but issue not solved..
    <?
    $sql2="select * from pages where id between 1 AND 7";
    $result2=mysql_query($sql2);

    while($row2=mysql_fetch_array($result2))
    {
    ?>

    <li><? $id=$row2["id"];?><a href="header-pages.php?page=<?echo urlencode($id);?>" ><? echo $row2[pagename]; ?></a></li>
    <?
    }
    ?>
     
    Om ji Kesharwani, Nov 11, 2009 IP
  19. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #19
    Change

    <li><? $id=$row2["id"];?><a href="header-pages.php?page=<?echo urlencode($id);?>" ><? echo $row2[pagename]; ?></a></li>

    to

    <li><? $id=$row2["id"];?><a href="http://0532.co.in/header-pages/<?echo urlencode($id);?>.html" ><? echo $row2[pagename]; ?></a></li>
     
    Bohra, Nov 11, 2009 IP
  20. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Om ji Kesharwani, Nov 11, 2009 IP