Results 1 to 7 of 7

Thread: .htaccess

  1. #1

    Default .htaccess


    php freaks.. patabang ta ko aning htaccess, pasensya mo 0 balance ko aning php og apache.. nag deploy rako..


    provided the below folder structure

    Code:
    www (root)
    ...subfolder1
    .......subfolder2
    using htaccess how to redirect all request for subfolder1 to subfolder2

    eg: localhost/subfolder1 --- if this is the request it should redirect to subfolder2, provided that subfolder2 has an index.

  2. #2

    Default Re: .htaccess

    Quote Originally Posted by fixyourself View Post
    php freaks.. patabang ta ko aning htaccess, pasensya mo 0 balance ko aning php og apache.. nag deploy rako..


    provided the below folder structure

    Code:
    www (root)
    ...subfolder1
    .......subfolder2
    using htaccess how to redirect all request for subfolder1 to subfolder2

    eg: localhost/subfolder1 --- if this is the request it should redirect to subfolder2, provided that subfolder2 has an index.
    there two approach on this you can either go for dynamic approach or static approach


    Dynamic:

    PHP Code:
    <IfModule mod_rewrite.c>
    Options -Indexes
    RewriteEngine On
    RewriteBase 
    /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond 
    %{REQUEST_FILENAME} !-d
    RewriteRule 
    . /index.php [L]
    </
    IfModule
    Options -Indexes = prevents accessing directory without and index

    Use php to check the uri and redirect it to where ever you intended to be
    to access the URI you can use:
    PHP Code:
    $pu parse_url($_SERVER['REQUEST_URI']);
    $pathinfo pathinfo($pu['path']); 
    PHP: parse_url - Manual
    PHP: pathinfo - Manual

    for dynamic websites mao ni ang usuall nga aproach... and the example above is how wordpress works

    Static:

    PHP Code:
    <IfModule mod_rewrite.c>
    Options -Indexes
    RedirectMatch 301 
    ^/subfolder1/.*$ http://yoursite.com/subfolder2/
    </IfModule
    PHP Code:
    RedirectMatch 301 ^/subfolder1/.*$ http://yoursite.com/subfolder2/ 
    pretty simple but not flexible, since we already declare Options -Indexes it will now return and error, you can now customize your error page by adding ErrorDocument line

    PHP Code:
    <IfModule mod_rewrite.c>
    Options -Indexes
    RedirectMatch 301 
    ^/subfolder1/.*$ http://yoursite.com/subfolder2/
    ErrorDocument 404 /404.php
    </IfModule

  3. #3

    Default Re: .htaccess

    salamat bai...daghana solution oi, nosebleed ko

    anyways akong gibuhat nlang kai..

    gi redirect tanan request for subfolder1 via htaccess to index.php under subfolder1, then included index.php of subfolder2, sa kato nga index.

    Code:
    <?php
    require_once '/subfolder2/index.php';
    ?>

  4. #4

    Default Re: .htaccess

    Quote Originally Posted by fixyourself View Post
    salamat bai...daghana solution oi, nosebleed ko

    anyways akong gibuhat nlang kai..

    gi redirect tanan request for subfolder1 via htaccess to index.php under subfolder1, then included index.php of subfolder2, sa kato nga index.

    Code:
    <?php
    require_once '/subfolder2/index.php';
    ?>
    thats one straight forward solution kay dili raba tanan server na enable ang mod_rewrite, if mao nay situation mao pud na ako buhaton...

  5. #5
    Hi. Kinsa maayo mo rewrite ani .htaccess? Pa tabang ta ko ako site kay na yabag.

  6. #6
    fix na imo site?

  7. #7
    Have you been able to solve your problem honestly, I do know many requests being done with that help and plan to do the same afterwords, but you can always look in google, probably some person already had some solution for your case anyway.

  8.    Advertisement

Similar Threads

 
  1. a little help with .htaccess please. :)
    By emailroy2002 in forum Programming
    Replies: 5
    Last Post: 01-28-2009, 05:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top