hiding a subfolder

New to mod_rewrite? This is a good place to start.

hiding a subfolder

Postby 11Schollen » Wed Sep 23, 2009 2:30 am

hi. i redirected my tld to my working directory with a 301.

now i want to hide the subdirectory in the url so

www.example.com/dir/... --> www.example.com/...

i tried to figure it out myself, but im just too new to this rewrite thing XD

would appreciate any help. thanks!
11Schollen
 
Posts: 1
Joined: Wed Sep 23, 2009 2:20 am

Postby richardk » Wed Sep 23, 2009 9:51 am

Try
Code: Select all
Options +FollowSymLinks

# Add missing trailing slashes.
# Check if it's a request to a directory in /dir
RewriteCond %{DOCUMENT_ROOT}/dir%{REQUEST_URI}/ -d
# If it doesn't end in a slash, redirect to add one.
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

# /* to /dir/*
# Don't match internal requests.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.*)$ /dir/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 21 guests

cron