Jump to content

File output.


The Little Guy

Recommended Posts

No, that isn't what I want, that is what I have... it doesn't work.

 

My site routes sub domains through a file using htaccess, and that file creates the output for the page, so it displays like a normal website. The problem is, that CSS files, and JavaScript files display as normal HTML output, and that the line breaks are not put in, and it isn't formated like a normal css document.

 

Here is my sites output:

http://test.hostbox.us/style.css

 

Here is a normal sites output:

http://tzfiles.com/style.css

 

see how the formatting is different? I would like the first one to display like the second one.

Link to comment
https://forums.phpfreaks.com/topic/83017-file-output/#findComment-422263
Share on other sites

You are sending the wrong content type header for the first link (http://test.hostbox.us/style.css). Your browser is receiving the text/html content type and thus the new lines are not displaying. You will need to send the text/css content type header in order for the browser to display the newlines.

 

How is style.css being routed. Could you explain your setup.

Link to comment
https://forums.phpfreaks.com/topic/83017-file-output/#findComment-422319
Share on other sites

.htaccess file:

Options +FollowSymLinks

RewriteEngine On

# Fix missing trailing slashes.
RewriteCond %{HTTP_HOST} !^(www\.)?hostbox\.us$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.hostbox\.us$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%2%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

# Rewrite sub domains.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^(www\.)?hostbox\.us$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.hostbox\.us$ [NC]
RewriteRule ^(.*)$ viewFile.php?user=%2&file=$1 [QSA,L]
#RewriteRule ^(.*)$ subdomains/%2/$1 [QSA,L]

 

The line to output the CSS/JS is on about line 15

 

The file that actually displays the output:

<?php
$file = '/home/ryannaddy/hostbox.us';
if(isset($_GET['file'])){
	if(empty($_GET['file'])&&file_exists($file.'/subdomains/'.$_GET['user'].'/index.php')){$f = 'index.php';$s = 'index.php';}
	elseif(empty($_GET['file'])&&file_exists($file.'/subdomains/'.$_GET['user'].'/index.htm')){$f = 'index.htm';$s = 'index.htm';}
	elseif(empty($_GET['file'])&&file_exists($file.'/subdomains/'.$_GET['user'].'/index.html')){$f = 'index.html';$s = 'index.html';}
	else{$s = $_GET['file'];$f = $_GET['file'];}
}else{
	$f = $_GET['file'];
	$s = $_GET['file'];
}
$file .= '/subdomains/'.$_GET['user'].'/'.$f;
if(file_exists($file)){
	if(preg_match("~^(.*).(css|js)$~",$file)){
		readfile($file);
	}else{
		echo'<div style="margin:auto;width:728px;padding-bottom:5px;">
			<script type="text/javascript"><!--
				google_ad_client = "pub-6797482378713025";
				//hostbox.us Header
				google_ad_slot = "5160918041";
				google_ad_width = 728;
				google_ad_height = 90;
				//--></script>
				<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
			</script>
		</div>';
		include $file;
	}
}else{
	header("HTTP/1.0 404 Not Found");
	include('/home/ryannaddy/hostbox.us/err/404.php');

}
?>

Link to comment
https://forums.phpfreaks.com/topic/83017-file-output/#findComment-422448
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.