SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question rewrite question

    Hi,

    Let say that i have a website stored in /public_html/subfolder/
    .htaccess is stored in /public_html

    when user type (in browser) www.mywebsite.com, he should be redirected to /public_html/subfolder/index.html
    however user should only see in browser address bar www.mywebsite.com and not www.mywebsite.com/subfolder/

    this i solved using:
    Code:
    RewriteBase /
    
    #Rewrites http://www.website.com/subfolder to http://www.website.com/
    RewriteCond %{REQUEST_URI} !^/subfolder
    RewriteRule ^(.*)$ subfolder/$1 [L]
    this works....
    now, let say that website allow admin login using /public_html/subfolder/admin/
    i would like to display only http://www.website.com/admin/ and not as it is now: http://www.website.com/subfolder/admin/

    therefore i was thinking to add to previous code:
    Code:
    #Rewrites http://www.website.com/subfolder/admin/ to http://www.website.com/admin/
    RewriteCond %{REQUEST_URI} !^/subfolder/admin/
    RewriteRule ^(.*)$ subfolder/admin/$1 [L]
    but this does not work.
    Any idea where is my mistake ?
    thx

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,259
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Your first rewrite rule should take care of that already. I did a quick test on my local machine to be sure.
    "First make it work. Then make it better."

  3. #3
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jeff Mott View Post
    Your first rewrite rule should take care of that already. I did a quick test on my local machine to be sure.
    Partially it does, but it does not rewrite it well as i have http://www.mywebsite.com/subfolder/admin/
    and i would like to have http://www.mywebsite.com/admin/

  4. #4
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,259
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by alain.roger View Post
    Partially it does, but it does not rewrite it well as i have http://www.mywebsite.com/subfolder/admin/
    and i would like to have http://www.mywebsite.com/admin/
    When I used your rewrite rule on my local machine, it did exactly that. If it isn't working for you, then there must be something else significant in your htaccess that we haven't seen.
    "First make it work. Then make it better."


Bookmarks

Posting Permissions

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