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 9 of 9
  1. #1
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts

    .htaccess redirect question

    I have a php include section in my site using this format:
    http://site.com/css/index.php?page=pagename
    I was wondering if there was a way, using .htaccess, to redirect this:
    http://site.com/css/contact.php
    to:
    http://site.com/css/index.php?page=contact
    I want this because my template is on index.php along with a menu and other things and ?page= is included in a box in the middle of the page.

    Thanks,
    GO ILLINI
    Why not thank me?

    http://adamsworld.name

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    I think you're looking for mod_rewrite.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    how do I usae that? is that a php or a .htaccess solution? If it is .htaccess solution is it one like where you can redirect an entire directory instead of typing out all the filenames? like
    Redirect /olddir/ http://newsite/
    ?
    Why not thank me?

    http://adamsworld.name

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Apache.
    Yes.
    http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

    See the part about RewriteRule.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    so RewriteRule /hosting/(.*) /hosting/?page\%3d$1 [R,NE] would go in my .htaccess?
    I tried that but it didn't work.
    I have absolutely no expierence with this.
    Why not thank me?

    http://adamsworld.name

  • #6
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Did you turn rewrite on?
    i.e.
    RewriteEngine on

    See this tutorial.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #7
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    thank you for the help but I have found a way taht I understand better.
    using php to define a var in the template and then seeing if the var exist on the actual page.
    eg:
    template.php:
    PHP Code:
    <?php $pageCheck "1" ?>
    links.php:
    PHP Code:
    <?php
    if($pageCheck=="1") { }
    else {
    header("Location: index.php?page=links")
    }
    ?>
    (just used links page as an example.)
    This will not be hard as there only going to be about 10 pages in the directory.
    Why not thank me?

    http://adamsworld.name

  • #8
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Lucky you, only 10 pages.
    Glad you found a solution.

    / has over 120 pages in some of her sites

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #9
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    ohh ya the site has about 250 pages total. I have like 5 seperate "sites" with subdomains included. I run a personal, css, forum, freak of the week(dont ask), web hosting, and like 2 more.
    I have 1 domain with 26 subdomains total.
    But this is only a mini site thing. Its part of the hosting site.
    Why not thank me?

    http://adamsworld.name


  •  

    Posting Permissions

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