[ACCEPTED]-.htaccess URL Rewrite to Subdirectory-rewrite
Accepted answer
This is the solution I finally got to work:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/some/subdir/projects/.*$
RewriteRule ^(.*)$ /some/subdir/projects/$1 [L]
0
Try this rule in your .htaccess configuration 5 file in the document root of your server:
RewriteEngine on
RewriteRule !^some/subdir/projects(/|$) some/subdir/projects%{REQUEST_URI} [L]
As 4 you want to use this rule in your /some/subdir/
directory, change 3 the rule as follows:
RewriteRule !^projects(/|$) projects%{REQUEST_URI} [L]
And if you want to redirect 2 any requests of /some/subdir/projects/
foobar
to /some/subdir/
foobar
, put this rule above 1 the previous mentioned:
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /some/subdir/projects[/?\s]
RewriteRule ^some/subdir/projects/?([^/].+)?$ /some/subdir/$1 [L,R=301]
I would use this:
RewriteEngine On
RewriteRule ^(/some/subdir)/(.*)$ $1/projects/$2
This will redirect /some/subdir/<anything>
to 3 /some/subdir/projects/<anything>
.
Note that the leading /
is actually required 2 to match the beginning of the URL, unless you 1 have RewriteBase /
set somewhere.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.