/    Sign up×
Community /Pin to ProfileBookmark

Redirect a directory to one page in same directory?

Hello. =)

I have a quick question: is there a way to make an entire directory redirect to one page in the [U]same[/U] directory?

So for instance, if you type:
[url]www.example.com/[/url][COLOR=”Green”]MYSITE/index.html[/COLOR]
[url]www.example.com/[/url][COLOR=”Green”]MYSITE/profile.html[/COLOR]
[url]www.example.com/[/url][COLOR=”Green”]MYSITE/news/old/2008.html[/COLOR]

…they’ll all redirect you to [url]www.example.com/[/url][COLOR=”Red”]MYSITE/important.html[/COLOR] ?

That’s all I wanted to ask. =) Thanks in advance!

to post a comment
HTML

5 Comments(s)

Copy linkTweet thisAlerts:
@kiwibritMay 03.2009 — just_bri , I wonder if Redirect 301 /MYSITE http://www.MYSITE/important.html in your .htaccess file might do the trick.
Copy linkTweet thisAlerts:
@just_briauthorMay 03.2009 — Thank you both for the ideas! [I](I'll definitely write them down; I like learning new HTML tricks)[/I]

However, I'm pretty sure what I need is a custom 404 page. I'm actually going to be emptying one directory [I](I'll call this [B]siteA[/B])[/I], and moving my site to another directory ([B]siteB[/B]) instead.

But, if someone tries entering a URL for siteA [I](and I'm sure someone will; I've had my site in there for years)[/I], there won't be any pages in there anymore. So I think I'd need a custom 404 page that'll mention [I](and then redirect them)[/I] to the new site location.

I've already tested one out [I](in a dummy directory I made)[/I], and I think it'll work fine. =)

Or, should I use something other than a 404 page?
Copy linkTweet thisAlerts:
@kiwibritMay 03.2009 — If a 301 redirect will do the trick, why make your visitors go through a 404?
Copy linkTweet thisAlerts:
@just_briauthorMay 03.2009 — Well, I've tried that 301 trick before, and it keeps messing up. =(

After I put that code in the .htaccess file, I'll try opening up another page in that same directory [I](ex: I'll open [B]profile.html[/B])[/I]. It should redirect me to important.html.

But instead, the URL looks like this:

[COLOR="Purple"]http://www.example.com/MYSITE/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/important.html/[B]profile.html[/B][/COLOR]

*It lists waaay too many "important.html" pages.

*
It still tacks on the original page I tried to open (which was profile.html)

Also as a sidenote, I didn't list the fake URL as www.MYSITE.com/ -- I listed it as www.example.com[B]/MYSITE[/B].

So, I'm trying to redirect things from a sub-directory, not the root directory. Maybe that's why the 301 redirect won't work?
×

Success!

Help @just_bri spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...