views:

17

answers:

1

I have two websites:

http://example.com http://example.com/sub

I have a page, let's say:

http://example.com/sub/page1

Is there any way (using .htacces) to make it possible to access page1 via this url:

http://example.com/page1?

Redirect 301 won't do the work, because I don't need redirects. Is there any way to omit '/sub/' for certain urls, like http://example.com/sub/page1 ?

+1  A: 

Yep, there is. Do the following within your .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On

# This would rewrite any URL that starts with /sub to /
RewriteCond %{REQUEST_URI} /sub
RewriteRule ^sub/(.*)$ /$1 [L]
<IfModule>

Edited to meet the OP's requirements.

aefxx
Well, this rewrites to /sub/, but I need a reverse action, from /sub/ to root.
Andersson83
Oh, ok. Apparently I need to read more thoroughly. My bad.
aefxx