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

Mailing List Archive: Apache: Users

Apache server - Output to the same page whatever request

 

 

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


liormin at smile

Oct 9, 2008, 11:16 AM

Post #1 of 7 (249 views)
Permalink
Apache server - Output to the same page whatever request

Hey people, I need your help, thanks in advance!

I have an appche server 2.x. + PHP, And I woundered rather it is possible
to output the same page (i.e. "a.php") for a request of whatever page.

I will give an examples:

if the client try to reach "/hello/index.php" (which do not really exist in
the server)

Can apache just tell the client -> I return you that page (/hello/index.php)
but infact, this page's content is "a.php"'s content.
wiout 404 Errors and stuff?

Thanks again

Lior.
--
View this message in context: http://www.nabble.com/Apache-server---Output-to-the-same-page-whatever-request-tp19904387p19904387.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
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.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org


justinp at newmediagateway

Oct 9, 2008, 2:22 PM

Post #2 of 7 (246 views)
Permalink
Re: Apache server - Output to the same page whatever request [In reply to]

MierMier wrote:
> Hey people, I need your help, thanks in advance!
>
> I have an appche server 2.x. + PHP, And I woundered rather it is possible
> to output the same page (i.e. "a.php") for a request of whatever page.
>
> I will give an examples:
>
> if the client try to reach "/hello/index.php" (which do not really exist in
> the server)
>
> Can apache just tell the client -> I return you that page (/hello/index.php)
> but infact, this page's content is "a.php"'s content.
> wiout 404 Errors and stuff?
>
> Thanks again
>
> Lior.

A RewriteRule that performs an internal rewrite should give you what you
need

RewriteEngine on
RewriteRule ^/hello/index.php$ /a.php [L]

By default, the rewrite will perform an internal rewrite, as opposed to
a 301/302 redirect. If the setup is a little more complex than what you
describe above, then it may require some additional rules (such as
redirecting a request for ANY arbitrary file that does not exist). You
can explore the "RewriteCond -f" directive to make it smarter in that case.

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond


--
Justin Pasher

---------------------------------------------------------------------
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.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org


liormin at smile

Oct 9, 2008, 5:17 PM

Post #3 of 7 (243 views)
Permalink
Re: Apache server - Output to the same page whatever request [In reply to]

Justin Pasher wrote:
>
> MierMier wrote:
>> Hey people, I need your help, thanks in advance!
>>
>> I have an appche server 2.x. + PHP, And I woundered rather it is possible
>> to output the same page (i.e. "a.php") for a request of whatever page.
>>
>> I will give an examples:
>>
>> if the client try to reach "/hello/index.php" (which do not really exist
>> in
>> the server)
>>
>> Can apache just tell the client -> I return you that page
>> (/hello/index.php)
>> but infact, this page's content is "a.php"'s content.
>> wiout 404 Errors and stuff?
>>
>> Thanks again
>>
>> Lior.
>
> A RewriteRule that performs an internal rewrite should give you what you
> need
>
> RewriteEngine on
> RewriteRule ^/hello/index.php$ /a.php [L]
>
> By default, the rewrite will perform an internal rewrite, as opposed to
> a 301/302 redirect. If the setup is a little more complex than what you
> describe above, then it may require some additional rules (such as
> redirecting a request for ANY arbitrary file that does not exist). You
> can explore the "RewriteCond -f" directive to make it smarter in that
> case.
>
> http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond
>
>
> --
> Justin Pasher
>
> ---------------------------------------------------------------------
> 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.apache.org
> " from the digest: users-digest-unsubscribe[at]httpd.apache.org
> For additional commands, e-mail: users-help[at]httpd.apache.org
>
>
>

Hi paul,

I tried to read this guid and it seems to be a bit complicated... can you
maybe help me out a bit?

Le'ts take the example I wrote above.

If I go to /a/page1.php?c=1
Or I go to /a/page6.php?c=3&d=4

and I want the server to output a.php's content while he also recives the
GET request arguments of page1/2..

How (the hell hehe) do I do that?

Thanks in Advance!



--
View this message in context: http://www.nabble.com/Apache-server---Output-to-the-same-page-whatever-request-tp19904387p19909806.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
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.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org


liormin at smile

Oct 9, 2008, 5:18 PM

Post #4 of 7 (243 views)
Permalink
Re: Apache server - Output to the same page whatever request [In reply to]

MierMier wrote:
>
>
>
> Justin Pasher wrote:
>>
>> MierMier wrote:
>>> Hey people, I need your help, thanks in advance!
>>>
>>> I have an appche server 2.x. + PHP, And I woundered rather it is
>>> possible
>>> to output the same page (i.e. "a.php") for a request of whatever page.
>>>
>>> I will give an examples:
>>>
>>> if the client try to reach "/hello/index.php" (which do not really exist
>>> in
>>> the server)
>>>
>>> Can apache just tell the client -> I return you that page
>>> (/hello/index.php)
>>> but infact, this page's content is "a.php"'s content.
>>> wiout 404 Errors and stuff?
>>>
>>> Thanks again
>>>
>>> Lior.
>>
>> A RewriteRule that performs an internal rewrite should give you what you
>> need
>>
>> RewriteEngine on
>> RewriteRule ^/hello/index.php$ /a.php [L]
>>
>> By default, the rewrite will perform an internal rewrite, as opposed to
>> a 301/302 redirect. If the setup is a little more complex than what you
>> describe above, then it may require some additional rules (such as
>> redirecting a request for ANY arbitrary file that does not exist). You
>> can explore the "RewriteCond -f" directive to make it smarter in that
>> case.
>>
>> http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond
>>
>>
>> --
>> Justin Pasher
>>
>> ---------------------------------------------------------------------
>> 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.apache.org
>> " from the digest: users-digest-unsubscribe[at]httpd.apache.org
>> For additional commands, e-mail: users-help[at]httpd.apache.org
>>
>>
>>
>
> Hi paul,
>
> I tried to read this guid and it seems to be a bit complicated... can you
> maybe help me out a bit?
>
> Le'ts take the example I wrote above.
>
> If I go to /a/page1.php?c=1
> Or I go to /a/page6.php?c=3&d=4
>
> and I want the server to output a.php's content while he also recives the
> GET request arguments of page1/2..
>
> How (the hell hehe) do I do that?
>
> Thanks in Advance!
>
>
>
>

*Pasher :] sorry
--
View this message in context: http://www.nabble.com/Apache-server---Output-to-the-same-page-whatever-request-tp19904387p19909814.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
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.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org


mearns.b at gmail

Oct 9, 2008, 6:38 PM

Post #5 of 7 (238 views)
Permalink
Re: Apache server - Output to the same page whatever request [In reply to]

The QSA option is what you need to pass the GET arguments along to the
rewritten url. For instance, if you want EVERY url to get served by
a.php, including GET arguments, you can do:

RewriteRule ^.*$ /a.php [QSA]


I'm pretty sure that's the write matching pattern to match anything,
but whether it is or not, the QSA option should do what you want.

Hope that helps.

-Brian

---------------------------------------------------------------------
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.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org


liormin at smile

Oct 14, 2008, 12:20 PM

Post #6 of 7 (185 views)
Permalink
Re: Apache server - Output to the same page whatever request [In reply to]

MierMier wrote:
>
> Hey people, I need your help, thanks in advance!
>
> I have an appche server 2.x. + PHP, And I woundered rather it is possible
> to output the same page (i.e. "a.php") for a request of whatever page.
>
> I will give an examples:
>
> if the client try to reach "/hello/index.php" (which do not really exist
> in the server)
>
> Can apache just tell the client -> I return you that page
> (/hello/index.php) but infact, this page's content is "a.php"'s content.
> wiout 404 Errors and stuff?
>
> Thanks again
>
> Lior.
>

Well thanks alot, but somhing went wrong, and after reading, still can't
understand why.

I have an Apache server server on my PC, based on WinXP,

and when I use these in .htaccess

Options +FollowSymLinks

RewriteEngine On
RewriteRule ^.*$ /a.php [QSA]

it works well.
How ever at my Linux apache server server it doesn't, it always show me 404
error, and the rewrite mod is enabled.

Any ideas?


--
View this message in context: http://www.nabble.com/Apache-server---Output-to-the-same-page-whatever-request-tp19904387p19980343.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
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.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org


solprovider at apache

Oct 15, 2008, 6:51 AM

Post #7 of 7 (182 views)
Permalink
Re: Apache server - Output to the same page whatever request [In reply to]

On 10/14/08, MierMier <liormin[at]smile.net.il> wrote:
> MierMier wrote:
> > I have an appche server 2.x. + PHP, And I woundered rather it is possible
> > to output the same page (i.e. "a.php") for a request of whatever page.
> >
> > I will give an examples:
> > if the client try to reach "/hello/index.php" (which do not really exist
> > in the server)
> >
> > Can apache just tell the client -> I return you that page
> > (/hello/index.php) but infact, this page's content is "a.php"'s content.
> > wiout 404 Errors and stuff?
> > Lior.
>
> Well thanks alot, but somhing went wrong, and after reading, still can't
> understand why.
>
> I have an Apache server server on my PC, based on WinXP,
> and when I use these in .htaccess
> Options +FollowSymLinks
> RewriteEngine On
> RewriteRule ^.*$ /a.php [QSA]
>
> it works well.
> How ever at my Linux apache server server it doesn't, it always show me 404
> error, and the rewrite mod is enabled.
>
> Any ideas?

The querystring is passed to redirected pages by default if the
redirect does not contain a question mark. Ending with a querystring
overwrites the querystring with the new values. Ending the redirect
with a question mark clears the original values -- no new values. The
QSA (QueryString Append) option merges new querystring values with the
original values, unecessary without new querystring values See
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

Status 404 is "Not Found". Does /a.php exist? Can httpd read it?
File permission issues?

Redirecting error pages may not require a RewriteRule or even
mod_rewrite. "ErrorDocument" is a core command. Try:
ErrorDocument 404 /a.php
The documentation does not mention how ErrorDocument handles the
original querystring. See:
http://httpd.apache.org/docs/2.2/mod/core.html#errordocument

HTH,
solprovider

---------------------------------------------------------------------
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.apache.org
" from the digest: users-digest-unsubscribe[at]httpd.apache.org
For additional commands, e-mail: users-help[at]httpd.apache.org

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


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.