homepage Welcome to WebmasterWorld Guest from 54.226.173.169
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Redirect to hidden dir
thenewbe




msg:4666327
 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

 

lucy24




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

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
/dir1/dir2/dir3/index.php?long-pointless-boring-parameter=equally-long-pointless-boring-value
... 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
akdsjeotijfmcfklgjeroit.html
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.

thenewbe




msg:4666381
 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 http://www.mysite.com/theword 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.
phranque




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

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.

lucy24




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

Got it.

www.example.com/secretyummydir/specialpagename

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
URL
/specialpagename
to serve content from
/secretyummydir/specialpagename
or, for that matter,
/secretyummydir/index.php
but you need to make sure that nobody ever suspects the existence of
/secretyummydir/

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:
example.com/artists/jane.html
example.com/artists/maggie.html
example.com/artists/john.html
will inevitably lead someone to ask for
example.com/artists/
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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved