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 7 of 7

Thread: rewrite func

  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts

    rewrite func

    Hi, I want to rewrite some url's from a dir/folder/folder2 to mysite.com/contact.html via php, i dont know how, i've made come up with this func:
    PHP Code:
     NOTES >>
     * - 
    The array order is also the default sort order.
     * - 
    'live' values can be true/false
     
    * - 'title' values can use $lang[] values or any value.
     */

    $pages_config = array (
        
    'about'     => array('live' => true'title' => 'About Us'),
        
    'tos'         => array('live' => true'title' => 'Terms of Service'),
        
    'contact'    => array('live' => true'title' => 'Contact'),
    ); 
    now does any1 know hhow to go about this?

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,530
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Well, htaccess is the usual way to do this, or combining htaccess with a controller (it seems you wanna do the latter here. Unfortunately, I'm not a pro with htaccess, so hopefully someone else can help you figure out how to redirect individual pages to a controller rather then everything.

    Getting everything to forward to a page and then having that page pull pages is easy enough to do if you wanna go that route.

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts
    Yea, Keleth.

    That sounds spot on what I want to do, I really dont wanna mess with htaccess, atleast for these theme dir.

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,530
    Thanks
    45
    Thanked 259 Times in 256 Posts
    If you don't wanna mess with htaccess, then just use a PHP redirect?

    PHP Code:
    header('Location: newPage.ext'); 

  • #5
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts
    See, all my theme pages are in:

    content/themes/ [THEME NAME] / pages/file.php

    Ideally somehow I want, mysite.com/file.html

    So would header(); work?

  • #6
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,530
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Wait, so is it you don't want anyone to be able to access those folders? htaccess is ideal for that...

    But if you wanna throw a redirect, its exactly as I put above, just change newPage.ext for wherever you want it to point. And since it is a header, it has to be before anything is echoed to the page.

  • #7
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts
    I'm not bothered about them accessing, although a 301 would be great.

    hmm i'm reading htaccess redirect match...

    Can you help??????


  •  

    Posting Permissions

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