Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: htaccess help?

  1. #1
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts

    htaccess help?

    I have a site and i want to change its links, its a complicated script in php oop.

    i want to change a link like

    mysite.com/gallery/main

    to

    mysite.com/photos

    whats the rewrite rule for this?

    also theres a pregreplace for the url function

    PHP Code:
    $sUrl preg_replace('old url''new url'$sUrl); 
    i don't know how to set this up

  • #2
    Codeasaurus Rex
    Join Date
    Jun 2008
    Location
    Redmond, WA
    Posts
    660
    Thanks
    31
    Thanked 100 Times in 94 Posts
    Frankly I'm not 100% sure where you are asking for PHP.

    I recommend you thumb through this for mod_rewrite, http://www.easymodrewrite.com/. It's a great tutorial.

    Let us know if you've got another rewrite questions past that.

    For PHP, are you trying to get the links to change in your code to match your rewrite rule? Are you doing a global boolen on $rewrite_on = TRUE; for example?
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com

  • #3
    Regular Coder BWiz's Avatar
    Join Date
    Mar 2006
    Location
    Sol System
    Posts
    471
    Thanks
    7
    Thanked 21 Times in 21 Posts
    You could do that straight in your .htaccess file. No need for php.

    Code:
    RewriteEngine On
    RewriteRule ^gallery/main/?$ http://url.tld/photo
    BWiz :: Happy Coding!
    2006
    2007 2008 2009
    2010 2011
    Irrational numbers make no sense.


  •  

    Posting Permissions

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