Viewed   121 times

I have an Apache virtual host that looks like this:

<VirtualHost *:80>
    ServerName host1.example.com
    ServerAlias host2.example.com
    DocumentRoot /srv/web/host1.example.com/pub
</VirtualHost>

I have the following file:

/srv/web/host1.example.com/pub/test.php

I am requesting the following URL (notice that I am using the ServerAlias, not the ServerName:

http://host2.example.com/test.php

I'd like to have test.php output the ServerName variable somehow (host1.example.com). Is there any way to do that?

 Answers

3

Apparently, when you access a VirtualHost through the alias, there is no trace of the original SERVER_NAME in any of the $_SERVER variables.

The only idea that comes to mind is setting an environment variable:

SetEnv MY_HOST host1.example.com

this should set the value of $_SERVER["MY_HOST"] to the correct host name. No guarantees though, I have never tried this in practice.

Friday, November 4, 2022
 
4

Try to use xfilesend module for Apache.

Saturday, November 12, 2022
 
bill
 
4

If you use a newer version of PostgreSQL (> 8.1) you should use the RETURNING clause of INSERT (and UPDATE) command.

OTOH if you insist on using one of the sequence manipulation functions, please read the fine manual. A pointer: "Notice that because this is returning a session-local value, it gives a predictable answer whether or not other sessions have executed nextval since the current session did."

Thursday, November 10, 2022
 
2

This is a VHost I took from my httpd-vhosts.conf. The only extra configuration I made was to get around the 403 I was hitting:

<VirtualHost *:80>
    ServerName "Markdown.loc"
    ServerAlias "www.Markdown.loc"
    DocumentRoot "C:INTERNALPHPMarkdown"
    <Directory "C:INTERNALPHPMarkdown">
        Options +Indexes
        AllowOverride All
    </Directory>
</VirtualHost>

All my other VHosts look like this:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/somesite.loc"
    ServerName somesite.loc
    ServerAlias www.somesite.loc
</VirtualHost>

If you're simply looking to include something from a dir on the same level as your htdocs though, include("../includes/somefile.php") should work just fine.

If I've got your problem wrong, let me know, and I'll try to help you more.

Sunday, September 4, 2022
1

It will be quite easy, once you can pull down a timeline and display it, to then add some file-based-caching to it.

check age of cache
Is it more than 5 mins old?
    fetch the latest information
    regenerate the HTML for output
    save the finished HTML to disk
display the cached pre-prepared HTML

PEAR's Cache_Lite will do all you need on the caching layer.

Sunday, July 31, 2022
 
gent
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share