Wordpress and PHP prepend_file

Shadow121

Member
Messages
901
Reaction score
0
Points
16
Hey there!

I have posted on the wordpress support site and another website for coding and have had no response. But, I have several wordpress sites and I have PHP set for a prepend file. But, when I make it do something to affect all sites, it doesn't affect the wordpress sites.

Can anyone help me sort this out or give advice? Thanks!
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
That's not enough information. Please include a specific description of what you want/expect to happen and what actually happens (including any error messages), and enough to reproduce the issue.
 
Last edited:

Shadow121

Member
Messages
901
Reaction score
0
Points
16
I'm basically making a website suspension type thing using a prepended file set in the apache httpd.conf file. The only problem is, it won't redirect to the page I want after I set the site to be suspended. There are no errors. It just won't redirect.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Again, not enough info.

1. What are you doing in http.conf ?

2. What file are you prepending?

3. Are you saying foo.com , a non-Wordpress site using PHP, does what you want, but barr.org , a Wordpress site on the same server , does not do what you want?
 

Shadow121

Member
Messages
901
Reaction score
0
Points
16
In httpd.conf I have:
Code:
php_admin_value auto_prepend_file /mnt/secondary_hd/apache_sites/global/inc/suspended.php

Which will append the suspension check file to all websites. Wordpress completely ignores it and acts like there's nothing there whereas another website that isn't running Wordpress executes it without fail.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Sorry. Still not enough info.

If your code is so top secret that you don't want to share, fine.

If you really want help, post your code and your .htaccess file.
 

Shadow121

Member
Messages
901
Reaction score
0
Points
16
All I've explained is exactly how it works. Apache includes the file. The file checks a variable defined in a Vhost file. If the variable is 1 redirect to a new site. Nothing else.

httpd.conf
Code:
php_value auto_prepend_file /mnt/secondary_hd/apache_sites/global/inc/suspended.php

A vhost file
Code:
# games.wikiop.in<VirtualHost *:80>
        ServerAdmin someemail@notforpublicuse.tld
        SetEnv cid "2"
        SetEnv s_sus "1"
        ServerName games.wikiop.in
        ServerAlias www.games.wikiop.in
        DocumentRoot /mnt/secondary_hd/apache_sites/games
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /mnt/secondary_hd/apache_sites/games>
                Options All
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>


        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Suspended.php
PHP:
<?phpob_start();if($_SERVER['s_sus'] == 1){    Header('Location: http://control.wikiop.in/suspended/?d='.$_SERVER['SERVER_NAME']);}ob_end_flush();?>

There are no .htaccess files involved. Just those.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Have you tried to add a test.php page to the Wordpress site and see if the redirect works there (ie, WordPress never gets involved)?
 

Shadow121

Member
Messages
901
Reaction score
0
Points
16
Yes I have tried to and the test.php will redirect while the regular wordpress will not.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Have you tried calling exit after outputting the header?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Note how important it is to include code that gives a minimal test case (complete, concise, representative). Without it, we could only guess as to the issue. Follow the advice in my sig to improve your question asking skills.

Suspended.php
PHP:
<?phpob_start();if($_SERVER['s_sus'] == 1){    Header('Location: http://control.wikiop.in/suspended/?d='.$_SERVER['SERVER_NAME']);}ob_end_flush();?>

If this is the exact contents of the file, the lack of a space after the <?php tag will prevent this from being interpreted as a PHP script.

As for why header('Location: ...') doesn't work on WordPress sites, it often sets its own redirect, which will replace the one you set. descalzo gives the solution for this, but there's one more thing you should include. Setting "Location" with header() sets the response status to 302 by default. According to the HTTP 1.1 spec, § 10.3.3 302 Found:
Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).
 

Shadow121

Member
Messages
901
Reaction score
0
Points
16
So you're saying I should issue a new header such as 307 moved temporarily rather than leaving it as 302?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
No, I wrote:

Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).

I'm not sure how you got anything about a 307 response from that. You'd use a 307 if you wanted the user agent to repeat the request exactly (including the request method) for the new URI, which is unrelated to anything discussed in this thread previously.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
No, I wrote:



I'm not sure how you got anything about a 307 response from that. You'd use a 307 if you wanted the user agent to repeat the request exactly (including the request method) for the new URI, which is unrelated to anything discussed in this thread previously.

Why don't you just tell him what you think he should do?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
I did. More precisely, the HTTP spec does.
 
Top