NotGaeL
NotGaeL

Reputation: 8484

mod_rewrite on .htaccess to map main folder to subfolder

I'm trying a simple thing: Make Apache 2.2.15 respond to all requests to http://myserver/myfolder/* with http://myserver/myfolder/myproject/* (Except those to myproject)

So far I've tried placing several variants of the following .htaccess on myfolder:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^myproject
RewriteRule ^(.*)$ myproject/$1 [L]

why do I get a 500 internal error?

Upvotes: 2

Views: 375

Answers (2)

anubhava
anubhava

Reputation: 785246

Can you try this code:

RewriteBase /myfolder/

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

Upvotes: 2

Jon Lin
Jon Lin

Reputation: 143906

Your condition is failing:

RewriteCond %{REQUEST_URI} !^myproject

All %{REQUEST_URI} vars have a leading slash.

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/myproject
RewriteRule ^(.*)$ myproject/$1 [L]

Or if the myproject can be anywhere:

RewriteEngine On
RewriteCond %{REQUEST_URI} !/myproject
RewriteRule ^(.*)$ myproject/$1 [L]

If the htaccess file is in the /myfolder directory then try:

RewriteEngine On
RewriteBase /myfolder/
RewriteCond %{REQUEST_URI} !^/myfolder/myproject
RewriteRule ^(.*)$ myproject/$1 [L]

Upvotes: 1

Related Questions