Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Users

Redirect ANY request to one page

 

 

Apache users RSS feed   Index | Next | Previous | View Threaded


jknowlton at vp44

Nov 14, 2009, 8:34 AM

Post #1 of 4 (571 views)
Permalink
Redirect ANY request to one page

Hi all.
I am trying to have apache (2.2.14-1 from Debian) redirect any request to
a certain page. In the server root I have the single file "park.html" and
I want that all requests for resources (documents as well as folders) on
that domain be redirected to that particular page.
To be specific:
* Request: "www.domain.com" -> redirect "www.domain.com/park.html"
* Request: "www.domain.com/otherpage.php" -> "www.domain.com/park.html"
* Request: "www.domain.com/dir1/hello.cgi" -> "www.domain.com/park.html"
ecc..

I currently tried using the following rule: "RedirectMatch permanent
^(.*)$ /park.html" but it doesn't seem to work (results in an infinite
loop).
Since I need the redirect badly, I set up 404s to go to "park.html" but I
think that won't go so well with robots.
Any suggestions?
Thanks.

-JK


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
" from the digest: users-digest-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


glen.j.barber at gmail

Nov 14, 2009, 8:37 AM

Post #2 of 4 (532 views)
Permalink
Re: Redirect ANY request to one page [In reply to]

On Sat, Nov 14, 2009 at 11:34 AM, Jack Knowlton <jknowlton [at] vp44> wrote:
> Hi all.
> I am trying to have apache (2.2.14-1 from Debian) redirect any request to
> a certain page. In the server root I have the single file "park.html" and
> I want that all requests for resources (documents as well as folders) on
> that domain be redirected to that particular page.
> To be specific:
> * Request: "www.domain.com" -> redirect "www.domain.com/park.html"
> * Request: "www.domain.com/otherpage.php" -> "www.domain.com/park.html"
> * Request: "www.domain.com/dir1/hello.cgi" -> "www.domain.com/park.html"
> ecc..
>
> I currently tried using the following rule: "RedirectMatch permanent
> ^(.*)$ /park.html" but it doesn't seem to work (results in an infinite
> loop).

I would imagine that is because park.html is trying to redirect to
itself. You should have a rule before this to check if the page is
park.html, then stop processing.

> Since I need the redirect badly, I set up 404s to go to "park.html" but I
> think that won't go so well with robots.
> Any suggestions?
> Thanks.
>
> -JK
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe [at] httpd
>   "   from the digest: users-digest-unsubscribe [at] httpd
> For additional commands, e-mail: users-help [at] httpd
>
>



--
Glen Barber

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
" from the digest: users-digest-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


phil at philipwigg

Nov 14, 2009, 9:01 AM

Post #3 of 4 (534 views)
Permalink
Re: Redirect ANY request to one page [In reply to]

Hi,

Try using mod_rewrite. This configuration should work...

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/park.html$
RewriteRule (.*) /park.html [L, R]

This redirects any request except park.html. Note that if park.html
contains an image, css, or whatever, it's important to also have a
condition to not redirect that image. For example, let's say park.html
references an image called logo.gif in a folder called 'images', you
could use:-

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/park.html$
RewriteCond %{REQUEST_URI} !^/images/logo.gif$
RewriteRule (.*) /park.html [L, R]

Cheers,
Phil.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
" from the digest: users-digest-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


jknowlton at vp44

Nov 14, 2009, 9:36 AM

Post #4 of 4 (535 views)
Permalink
Re: Redirect ANY request to one page [In reply to]

On Sat, November 14, 2009 6:01 pm, Philip Wigg wrote:
> Hi,
>
> Try using mod_rewrite. This configuration should work...
>
> RewriteEngine On
> RewriteCond %{REQUEST_URI} !^/park.html$
> RewriteRule (.*) /park.html [L, R]
>
> This redirects any request except park.html. Note that if park.html
> contains an image, css, or whatever, it's important to also have a
> condition to not redirect that image. For example, let's say park.html
> references an image called logo.gif in a folder called 'images', you
> could use:-
>
> RewriteEngine On
> RewriteCond %{REQUEST_URI} !^/park.html$
> RewriteCond %{REQUEST_URI} !^/images/logo.gif$
> RewriteRule (.*) /park.html [L, R]
>
> Cheers,
> Phil.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe [at] httpd
> " from the digest: users-digest-unsubscribe [at] httpd
> For additional commands, e-mail: users-help [at] httpd
>
>


It works great. Thanks for the help!

-JK


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
" from the digest: users-digest-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd

Apache users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.