Reputation: 3526
I want to move all my web site files (even including index.php) into a subdirectory (for exp: "abc")
For example BEFORE:
public_html
index.php
a.file
directory
an.other.file
...
AFTER:
public_html
abc_directory
index.php
a.file
directory
an.other.file
...
I want everything to work, as it was before, but i don't want to make any redirections (visible).
People should enter "http://myexmaplesite.com/directory/an.other.file/" and by .htaccess apache serve them "http://myexmaplesite.com/abc_directory/directory/an.other.file/" BUT WITHOUT EXTERNAL REDIRECTS (301,302 etc.)
How could I route all requests to a subdirectory using mod_rewrite?
Upvotes: 3
Views: 556
Reputation: 655319
Try this mod_rewrite rule in your document root:
RewriteEngine on
RewriteRule !^directory/ directory%{REQUEST_URI} [L]
Or in general:
RewriteEngine on
RewriteCond $1 !^directory/
RewriteRule ^/?(.*) directory/$1 [L]
This should be even applicable in server or virtual host configurations.
Upvotes: 1
Reputation: 1996
Something like
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ directory/$1 [L,QSA]
Upvotes: 1