+ Reply to Thread
Results 1 to 7 of 7

Thread: htaccess help

  1. #1
    michellachtzichkrom53 is offline x10Hosting Member michellachtzichkrom53 is an unknown quantity at this point
    Join Date
    Jul 2011
    Posts
    4

    htaccess help

    Hi all

    I need some help with .htaccess
    How do I rewrite index.php?page=home

    to

    home.html

    thanx in advance

  2. #2
    Dead-i's Avatar
    Dead-i is offline Community Advocate Dead-i has a spectacular aura about
    Join Date
    Aug 2011
    Location
    United Kingdom
    Posts
    1,448

    Re: htaccess help

    Instead of using htaccess you could just add a bit of code to the top of index.php

    PHP Code:
    <?php
    if ($_GET['page'] == 'home') {
    header("location:home.html");
    }
    ?>
    Last edited by Dead-i; 09-03-2011 at 12:31 PM.

  3. #3
    albertdiones73 is offline x10Hosting Member albertdiones73 is an unknown quantity at this point
    Join Date
    Jun 2010
    Posts
    5

    Talking Re: htaccess help

    RewriteCond %{QUERY_STRING} ^page\=home(\&.+)?$
    RewriteRule ^index.php$ test.php


    Or if ever you want to preserve the $_GET 's

    RewriteCond %{QUERY_STRING} ^page\=home(\&.+)?$
    RewriteRule ^index.php$ test.php?%{QUERY_STRING}


    Then on .htaccess it'll look something like this

    <IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteCond %{QUERY_STRING} ^page\=home(\&.+)?$
    RewriteRule ^index.php$ test.php?%{QUERY_STRING}

    </IfModule>

  4. #4
    michellachtzichkrom53 is offline x10Hosting Member michellachtzichkrom53 is an unknown quantity at this point
    Join Date
    Jul 2011
    Posts
    4

    Question Re: htaccess help

    hi Thank you

    but how to make it work like this:

    if I type in the url:
    http://webradioo.x10.mx/home.html

    that .htaccess interprets this as:
    http://webradioo.x10.mx/index.php?p=home

    I now use this script, but it doesn't work that well yet:
    Code:
    RewriteBase /
    RewriteRule ^([^/]*)\.html$ index.php?%{QUERY_STRING} [NC]
    thank you in advance for your time and knowledge

  5. #5
    Dead-i's Avatar
    Dead-i is offline Community Advocate Dead-i has a spectacular aura about
    Join Date
    Aug 2011
    Location
    United Kingdom
    Posts
    1,448

    Re: htaccess help

    You can use HTML to redirect home.html. In between <head> and </head> type this:

    Code:
    <meta http-equiv="refresh" content="0;url=index.php?p=home">
    So, in your entire document, it might look like this:
    Code:
    <html>
    
    <head>
    <title>My Website</title>
    <meta http-equiv="refresh" content="0;url=index.php?p=home">
    </head>
    
    <body>
    </body>
    
    </html>

  6. #6
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: htaccess help

    Quote Originally Posted by Dead-i View Post
    You can use HTML to redirect home.html. In between <head> and </head> type this:
    That method is both inefficient (user makes two requests for one page) and does not scale.

    Code:
    RewriteBase /
    RewriteRule ^([^/]*)\.html$ index.php?p=$1 [NC QSA]
    Should work.
    Nothing is always absolutely so.

  7. #7
    albertdiones73 is offline x10Hosting Member albertdiones73 is an unknown quantity at this point
    Join Date
    Jun 2010
    Posts
    5

    Talking Re: htaccess help

    Code:
    RewriteRule ^home.html$ index.php?p=home&%{QUERY_STRING}
    That should do it

+ Reply to Thread

Similar Threads

  1. Replies: 5
    Last Post: 04-18-2011, 07:52 AM
  2. .htaccess + php.ini
    By extolcpusername in forum Free Hosting
    Replies: 1
    Last Post: 01-15-2010, 08:51 AM
  3. htaccess
    By huwad08 in forum Off Topic
    Replies: 1
    Last Post: 12-29-2009, 10:25 AM
  4. .htaccess
    By tomjkear in forum Programming Help
    Replies: 7
    Last Post: 05-02-2008, 04:23 AM
  5. htaccess.txt -> .htaccess
    By MaestroFX1 in forum Free Hosting
    Replies: 0
    Last Post: 04-22-2008, 04:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers