Remove folder name from URL file path

Currently the website’s files are located in the root folder with the following htaccess file

DirectoryIndex home.php

RewriteEngine on

## force www. ##
RewriteCond %{HTTP_HOST} !^www.truedesign.no$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]

## remove .php and re-direct any .php-addresses##
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\\ /([^.]+\\.)+php?\\ HTTP
RewriteRule (.+)\\.php?$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME}\\.php -f
RewriteRule ^(.*)$ $1.php

We want to move all our website files to a certain folder on the webspace to keep the root folder more tidy. I normally would just do something like this:

redirect 301 /index.html http://www.domain.com/foldername/

This would give URLs like www.domain.com/foldername/ or www.domain.com/foldername/filename

Is ther any way to remove ‘foldername’ from the URL? We really just want www.domain.com/filename and www.domain.com for the home page (although these files would be located in a folder).

Many thanks.

spirelli,

You’ve gone to a lot of trouble to reinvent the {IS_SUBREQ} using {THE_REQUEST} but it should work just fine! Congrats!

I’d not move those files, if I were you, but your mod_alias Redirect will work as you indend (for index.html but why not name the DirectoryIndex in foldername, too?). That will work for index.html and the 301 will take the directory move to the browser for relative links.

Okay, “remove foldername?” Certainly, mod_rewrite. Use a modified version of either your “loopy” code or either version of my (signature linked) “loopy” code. Be sure, though, to use the <base> tag to let browsers know which directory level to look for relative links!

Regards,

DK