Welcome to HostingForumz.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

redirecting if missing file or page

 
   Web Hosting Problem Solving Community! (Home) -> Apache RSS
Related Topics:
How to set Missing.html for the error page - I have created a file in my document root and made the following 500 "The server made a boo boo. # n.b. the single leading (") marks it as text, it does not get output #..

Missing jsvc tar file in Tomcat 6.0 - All: I the binary tar file for Tomcat 6.0. I find that it is missing the jsvc tar file. Where can I download it from? Thank you. Keith

ApacheModuleColdFusion.dll file missing in CFusion folder?? - is it port 80 I know CF is port 8500 but I''m running it through apache? and shouldn't the file to connect them be in the CFusion files I can't find them? Also if you can help running apache with cold fusion and am

how to deny file access yet allow that file to be displaye.. - I want to prevent someone stealing my flash files. I added an .htaccess file to the directory which access to: but I could still access I can put it in a directory outside the web root but..

Am I missing something here? - I am running Apache 4.3.4. After install all works well, but when I add the virtual server for my Pinnacle in using the entries below I can no longer the 'regular' server at port 80, I get page not found errors. I'm..
Next:  Audio Clips on The Economist site - How does they..  
Author Message
Troy Piggins

External


Since: Feb 18, 2008
Posts: 3



(Msg. 1) Posted: Mon Feb 18, 2008 7:04 am
Post subject: redirecting if missing file or page
Archived from groups: alt>apache>configuration (more info?)

At present my apache2 server gives a 404 message if someone tries
to access a non-existent page or file.

On some forums I have posted some links to photos in the past.
If I want to restructure my server so that those links are no
longer correct, is there a way in apache to attempt to redirect
them to the correct page? Or perhaps if someone clicks an old
link with a certain path in it, they can get a special 404
message? What do you recommend?

--
Troy Piggins | http://piggo.com/~troy _ __ (_) __ _ __ _ ___
| '_ \| |/ _` |/ _` |/ _ \
| .__/|_|\__, |\__, |\___/
|_| |___/ |___/

 >> Stay informed about: redirecting if missing file or page 
Back to top
Login to vote
patpro ~ Patrick Proniews

External


Since: May 30, 2005
Posts: 31



(Msg. 2) Posted: Mon Feb 18, 2008 7:04 am
Post subject: Re: redirecting if missing file or page [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <20080218164649.606 DeleteThis @usenet.piggo.com>,
Troy Piggins <usenet-0802 DeleteThis @piggo.com> wrote:

> At present my apache2 server gives a 404 message if someone tries
> to access a non-existent page or file.
>
> On some forums I have posted some links to photos in the past.
> If I want to restructure my server so that those links are no
> longer correct, is there a way in apache to attempt to redirect
> them to the correct page? Or perhaps if someone clicks an old
> link with a certain path in it, they can get a special 404
> message? What do you recommend?


it depends on your restructuration.
If you have moved /your/page.html to /your/old/page.html it's quite easy
to setup a .htaccess file (or <Directory ...> in httpd.conf) so that
error document will be a specially crafted php file that can create a
redirect proposal for the user.
(I don't think an automatic redirect triggered by an error is a good
thing).

I'm using this kind of trick on my server. After moving a bunch of
directories from /some-directory/ to /some-directory/my-new-dir/, I've
created a 404 error page in php, looking like this:

.../..
<body>
<p>Hello,<br />
The page you're looking for has probably moved</p>
<p>You can try to reach it at this address: <?php echo '<a
href="'.dirname($_SERVER[REQUEST_URI]).'/my-new-dir/'.ba
sename($_SERVER[REQUEST_URI]).'">'.dirname($_SERVER[REQUEST_URI]).'/my-ne
w-dir/'.basename($_SERVER[REQUEST_URI]).'</a>'
; ?></p>
</body>
.../..

and my virtualhost config contains:

<Directory /usr/local/www/host/some-directory>
ErrorDocument 404 /some-directory/404.php
../..
</Directory>


hope this helps,

patpro

--
A vendre ! http://www.patpro.net/blog/index.php/2008/01/12/133

 >> Stay informed about: redirecting if missing file or page 
Back to top
Login to vote
Troy Piggins

External


Since: Feb 18, 2008
Posts: 3



(Msg. 3) Posted: Mon Feb 18, 2008 7:04 am
Post subject: Re: redirecting if missing file or page [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

* patpro ~ Patrick Proniewski is quoted & my replies are inline
* below :
> In article <20080218164649.606 DeleteThis @usenet.piggo.com>,
> Troy Piggins <usenet-0802 DeleteThis @piggo.com> wrote:
>
>> At present my apache2 server gives a 404 message if someone tries
>> to access a non-existent page or file.
>>
>> On some forums I have posted some links to photos in the past.
>> If I want to restructure my server so that those links are no
>> longer correct, is there a way in apache to attempt to redirect
>> them to the correct page? Or perhaps if someone clicks an old
>> link with a certain path in it, they can get a special 404
>> message? What do you recommend?
>
> it depends on your restructuration.
> If you have moved /your/page.html to /your/old/page.html it's quite easy
> to setup a .htaccess file (or <Directory ...> in httpd.conf) so that
> error document will be a specially crafted php file that can create a
> redirect proposal for the user.
> (I don't think an automatic redirect triggered by an error is a good
> thing).
>
> I'm using this kind of trick on my server. After moving a bunch of
> directories from /some-directory/ to /some-directory/my-new-dir/, I've
> created a 404 error page in php, looking like this:
>
> ../..
> <body>
> <p>Hello,<br />
> The page you're looking for has probably moved</p>
> <p>You can try to reach it at this address: <?php echo '<a
> href="'.dirname($_SERVER[REQUEST_URI]).'/my-new-dir/'.ba
> sename($_SERVER[REQUEST_URI]).'">'.dirname($_SERVER[REQUEST_URI]).'/my-ne
> w-dir/'.basename($_SERVER[REQUEST_URI]).'</a>'
> ; ?></p>
> </body>
> ../..
>
> and my virtualhost config contains:
>
> <Directory /usr/local/www/host/some-directory>
> ErrorDocument 404 /some-directory/404.php
> ../..
> </Directory>
>
>
> hope this helps,

Yes. That looks exactly like what I want. Thanks for that.
I'll have a look in more detail later. Thanks again.

--
Troy Piggins | http://piggo.com/~troy _ __ (_) __ _ __ _ ___
| '_ \| |/ _` |/ _` |/ _ \
| .__/|_|\__, |\__, |\___/
|_| |___/ |___/
 >> Stay informed about: redirecting if missing file or page 
Back to top
Login to vote
D. Stussy

External


Since: Nov 01, 2007
Posts: 25



(Msg. 4) Posted: Wed Feb 20, 2008 4:10 pm
Post subject: Re: redirecting if missing file or page [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Troy Piggins" <usenet-0802 RemoveThis @piggo.com> wrote in message
news:20080218164649.606@usenet.piggo.com...
> At present my apache2 server gives a 404 message if someone tries
> to access a non-existent page or file.
>
> On some forums I have posted some links to photos in the past.
> If I want to restructure my server so that those links are no
> longer correct, is there a way in apache to attempt to redirect
> them to the correct page? Or perhaps if someone clicks an old
> link with a certain path in it, they can get a special 404
> message? What do you recommend?

Use the commands Redirect and RedirectMatch to 301 the users to the correct
page.
 >> Stay informed about: redirecting if missing file or page 
Back to top
Login to vote
Troy Piggins

External


Since: Feb 18, 2008
Posts: 3



(Msg. 5) Posted: Thu Feb 21, 2008 9:23 am
Post subject: Re: redirecting if missing file or page [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

* D. Stussy is quoted & my replies are inline below :
> "Troy Piggins" <usenet-0802.RemoveThis@piggo.com> wrote in message
> news:20080218164649.606@usenet.piggo.com...
>> At present my apache2 server gives a 404 message if someone tries
>> to access a non-existent page or file.
>>
>> On some forums I have posted some links to photos in the past.
>> If I want to restructure my server so that those links are no
>> longer correct, is there a way in apache to attempt to redirect
>> them to the correct page? Or perhaps if someone clicks an old
>> link with a certain path in it, they can get a special 404
>> message? What do you recommend?
>
> Use the commands Redirect and RedirectMatch to 301 the users to the correct
> page.

Thanks mate. That RedirectMatch does the trick nicely using
PCREs.

I had subdirs under dir "photos" according to dates:

..../photos/2007_08_30
..../photos/2008_03_31

and so on. The photos dir has become quite huge, so decided to
put yearly dirs in there, then the date ones under that:

..../photos/2007/2007_08_30
..../photos/2008/2008_03_31

But some forums I've posted photos to will have links to the
older URLs.

This solves that:

<Directory "/home/troy/public_html">
RedirectMatch permanent /~troy/photos/(200[0-9]{1})_(.*) http://piggo.com/~troy/photos/$1/$1_$2
</Directory>

Thanks for that.

--
Troy Piggins | http://piggo.com/~troy _ __ (_) __ _ __ _ ___
| '_ \| |/ _` |/ _` |/ _ \
| .__/|_|\__, |\__, |\___/
|_| |___/ |___/
 >> Stay informed about: redirecting if missing file or page 
Back to top
Login to vote
Display posts from previous:   
   Web Hosting Problem Solving Community! (Home) -> Apache All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]