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 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2012
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    htaccess - how could I remove a folder in the path?

    Hello!

    I have 2 problems with .htaccess .

    1) I have a path
    Code:
    http://www.myaccount.domain.com/katarina/index.php
    and I want to remove the folder katarina and to obtain

    Code:
    http://www.myaccount.domain.com/index.php
    How could I solve this problem?



    2) I have a path on localhost

    Code:
    http://127.0.0.1:8888/katarina/index.php
    and I want to remove the folder katarina and to obtain

    Code:
    http://127.0.0.1:8888/index.php
    (soI want to remove my folder "katarina")

    How could I solve this problem?



    Thank you!

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,302
    Thanks
    28
    Thanked 276 Times in 270 Posts
    Quote Originally Posted by milanello72 View Post
    I have 2 problems with .htaccess .

    1) I have a path
    Code:
    http://www.myaccount.domain.com/katarina/index.php
    and I want to remove the folder katarina and to obtain

    Code:
    http://www.myaccount.domain.com/index.php
    How could I solve this problem?



    2) I have a path on localhost

    Code:
    http://127.0.0.1:8888/katarina/index.php
    and I want to remove the folder katarina and to obtain

    Code:
    http://127.0.0.1:8888/index.php
    (soI want to remove my folder "katarina")

    How could I solve this problem?
    You could use:

    Code:
    rewriteCond %{REQUEST_URI} /katarina/index\.php
    rewriteRule .+ /index.php [redirect=301]
    Or, if you want to be less explicit about the file name (assuming that index.php is the directory default file):

    Code:
    rewriteCond %{REQUEST_URI} /katarina/(?:index\.php)?
    rewriteRule .+ / [redirect=301]
    Note that the index.php you're redirecting to needs to be a real file.
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

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