1

I have website where all the files were in the public_html root so my urls were http://foo.com/index.php

I have moved all my files into a bar directory so now the url is: http://foo.com/bar/index.php however I would like to rewrite the URLs so that the the directory bar is not shown in the urls and the site still appears as http://foo.com/index.php. What is the best way of achieving this? I have LAMP hosting and can change htaccess files.

Thanks in advance.

anubhava
  • 761,203
  • 64
  • 569
  • 643
Ben Paton
  • 1,432
  • 9
  • 35
  • 59

1 Answers1

2

Put this code in your .htaccess under public_html:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^((?!bar/).*)$ bar/$1 [NC,L]

Then you can access your website as http://foo.com/index.php

anubhava
  • 761,203
  • 64
  • 569
  • 643