Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Redirect to hidden dir



8:35 pm on Apr 27, 2014 (gmt 0)

I'm trying to redirect to a dir when the user types /theword. The redirect works fine but trying to figure out how to hide the dir in the URL or better display the dir as a bunch or characters to hide the dir name. For example, it would nice to display the URL if possible like - mysite/j#$*f < just an example. The j#$*f (This would be the masked dir of say thedir.

Right now I have -

 Redirect /theword http://www.mysite.com/thedir 


12:21 am on Apr 28, 2014 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

Wrong track entirely. A redirect will, by definition, result in a changed URL. You're telling the browser to make a new request; that's what "redirect" means.

What you can do is rewrite so the content really lives in some entirely different place, such as

... but you wouldn't really gain anything by this. You'd have to rewrite the URL globally, so URL + content is still one package.

Another route is to put the entire page inside an iFrame. The ultimate source would still be visible to anyone who takes the trouble to look at the page html, but it wouldn't be visible in the URL.

Either way, stay away from non-alphanumerics. Your server doesn't much like them. A simple
will do just as well. (Ask your cat to walk across the keyboard, and use the result as your physical filename.)

Third route is to put the material inside a protected directory where users have to login by some means before they can see it.

Fourth route is to attach a <noindex> tag, so the content will never show up in search engines, if that's what you are worried about.

Fifth route is ... Well, I'm getting tired.

Really, I think it will work better if you start by explaining, in English, what the underlying situation is and what you want to do about it. Set aside the whole redirect/rewrite question for now.


2:38 am on Apr 28, 2014 (gmt 0)

The situation is I want to hide the dir where the index.php is located. For example... mysite.com/i-want-to-hide-this/thepage.php

Right now if I comment out -
#Redirect /theword http://www.mysite.com/thedir
... when they type
it goes to a 404.. so the whole idea is I don't want them to know the dir (i-want-to-hide-this) because they will still be able to see the dir. If they know what the dir is then after I disable
#Redirect /theword http://www.mysite.com/thedir
they will be able to go to the page if they know the dir.


4:48 am on Apr 28, 2014 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

welcome to WebmasterWorld, thenewbe!

i'm still not entirely clear what you are trying to accomplish, but i'm guessing at this point you that probably want to be using mod_rewrite directives (RewriteRule) rather than mod_alias directives (Redirect).

you should redirect the unwanted url to the url you want to "display" to the user using the [R=301,L] flag.
if the "hidden" directory is where the resource actually exists, then you must also follow this with an internal rewrite from the external url to the internal url.
the internal rewrite does not use the [R] flag and you must specify a url relative to the root directory for the internal rewrite.


6:31 am on Apr 28, 2014 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

Got it.


only you don't want anyone to know that the rest of /secretyummydir/ exists? In that case, wouldn't it be simpler to just not serve content from the directory? This seems the best approach if you're dealing with new files or new directories. You can put things exactly where they need to be from the outset.

It's trivial to rewrite
to serve content from
or, for that matter,
but you need to make sure that nobody ever suspects the existence of

If a search engine finds it by accident, they will keep asking for it forever.

:: detour to check a few logs to verify that this in fact happens regularly ::

If it's necessary to maintain directories that contain page files, but no index file, just redirect the requests:
will inevitably lead someone to ask for
even if there's no such page. This is one situation where I think it's perfectly appropriate to redirect to the root-- or to some intermediate directory, if there is one-- because they had no business asking for the page in the first place.

Featured Threads

Hot Threads This Week

Hot Threads This Month