301 Redirect With PHP Http:// To Http://www.
I'm trying to redirect http://domainname.com to http://www.domainname.com using a 301, on all pages, that means it needs to go in the header file... Here's the code I have:
Quote# <?php
# if(!stristr($_SERVER["HTTP_HOST"], 'www')){
# header("HTTP/1.1 301 Moved Permanently");
# header("Location: http://www.domainname.com/" . $_SERVER["REQUEST_URI"]);
# exit();
# }
# ?>
The only thing is that it redirects every page to http://www.domainname.com/... including http://www.domainname.com/ How do I fix this? What's the solution? I'm assuming there's some more code that needs to go into it. The host doesn't allow me to do this in the htaccess file.
View Complete Forum Thread with Replies
Related Forum Messages:
Warning: Fopen(http://localhost/.. ?HTTP Wrapper Does Not Support Writeable Conn
I am able to create a pdf using php and ezpdf, its works fine, and display the pdf document in the current server page. But here are two things i wish to do, first store the pdf and than open, if possible in a new popup window? When i tried this function below, it gives me an error Error: Warning: fopen(http://localhost/pdf/files/tmp1/yasmina.pdf) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections. in C:Program FilesxampphtdocspdfpdfClassesAndFonts_009ecertificate.php on line 139 Could not open file to save PDF. Code:
View Replies !
301 Redirect Https To Http
All pages on my site can be served up either using http or https. I'd like to all non-ecommerce pages to be served only via http. I;m not a programmer but from what I've read it seems like some .htaccess redirect code would do the trick. My developer is telling me he is going to create a list of all pages that are allowed to be opened via https and redirect all the rest to http using php coding and not using .htaccess. Does this sound like the best way to do this?
View Replies !
Can't Redirect From HTTPS To HTTP In Firefox?
a page currently in HTTPS, I force the client to redirect to another page using HTTP under the same domain (e.g. abc.com), i.e. header("Location: http://www.abc.com/index.php"); IE successfully redirect to HTTP, but FF & Opera stay on the HTTPS
View Replies !
Redirect Visitors Not Coming From My URL Http://www.domain.com/
<? $from = getenv("HTTP_REFERER"); if ($from!= "http://www.domain.com/") /* If URL is invalid the following error message and proper link appears*/ {print(" Sorry you have tried to link to a page which does not accept visitors directly. <br> <a href=http://www.domain.com/>CLICK HERE</a> to enter"); exit;} ?> I'm using the above script to redirect visitors not coming from my URL http://www.domain.com/ and trying to access a certain page of my website. How can I add one more URL (e.g.; http://www.domain.com/page2.php) from where visitors are accepted?
View Replies !
Server HTTP Sends Or Streaming HTTP?
I was wondering if you guys had any ideas to constantly stream a webpage in case an announcement was posted or possibly pushing onto the browser information. What I basically want is for a user browsing my website to be notified of any new announcements. I thought about checking everytime he changes pages but then I realized that I want them to be notified as long as they have the page open even if it's minimized. So it would at best be a method to use php force send a msg after someone posts an announcement.
View Replies !
Questions About HTTP Headers Sent With PHP In HTTP Authentication
Here is an example from the PHP Manual <?php if ((!isset($_SERVER['PHP_AUTH_USER'])) || (1==1)) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'Text to send if user hits Cancel button' exit; } else { echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>"; echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</ p>"; } ?> Questions. 1. This is a status code not a header, right? = header('HTTP/ 1.0 401 Unauthorized'); 2. According to the change log in the PHP manual, starting with 4.4.2 and 5.1.2 the header function now prevents more than one header to be sent at once as a protection against header injection attacks. Does this mean if I make multiple header calls the headers will be sent in multiple response messages to the browser? Is this allowed? Can a server send multiple response messages to one request?] 3. If you hit the "cancel" button on the browser user name/password request dialog (as alluded to in the code snippet above), what message does the browser send to the server.
View Replies !
Can't Include 'http...foo.php', But Can Include 'http...foo.txt'
This seems weird, but when I use the following code, include 'http://www.foo.com/includes.php' includedfunction(); I am told that it is a call to an undefined function, but 'includedfunction' is on the server. the following includes work fine, and the run the called function with no trouble: include 'http://www.foo.com/includes.phtml' include 'http://www.foo.com/includes.txt' all three include.php,.phtml & .txt are on the server and are exactly identical. I am running php version 4.1.1.
View Replies !
HTTP Error And Parse Error - I Get HTTP, Friend Gets Parse :S
I have just finished making a script, which basically updates a users account depending on what button they pressed on the previous page, everything looks fine to me, but when I click a button, I get a big HTTP error page, but the strange thing is, when my friend press's a button, he gets a parse error. Code:
View Replies !
HTTP 403
I have finally managed to get Apache 2.2.4, PHP 5.2.0 and MySQL to talk to each other. Everything seems to work OK when dealing with databases but as soon as I use a php-script that use $_server the browser will throw me away and give me HTTP 403. It has worked before but that was before I got the communication to work with MySQL
View Replies !
HTTP/URL
In cURL or Filesystem is there a function that will send data to a url. Like if I wanted to request a url with a specific string in the body how could I do this? I can't find anything.
View Replies !
Http Or Https ??
What variable might i be able to extract the http:// or https:// from to detect which type it is? On my server i have $_SERVER['SCRIPT_URI'] which contains htis but my friend does not have this variable on his server.
View Replies !
HTTP Authentication With PHP
I have followed 3 different tutorials and none of them seem to work. When I use the following code in the beginning of my PHP script: if (!isset($PHP_AUTH_USER)) { header('WWW-Authenticate: Basic realm="Datacenter"'); header('HTTP/1.0 401 Unauthorized'); echo 'Authorization Required.' exit; } and I attempt to access the script I get the error: "Error 500: Internal Server Error" I reset the permissions to 755 and still no luck. I then, out of frustration created a .htaccess file and tried every possible combination, particularly in the UserAuthFile. I have tried, UserAuthFile [path]/myscritp.php4 UserAuthFile /dev/null/ I have also tried deleting the line alltogether and what happens in all these cases is that the box comes up but when I enter the info it does not send the variable to the script. If you have any information I would really appreciate it. I could even send you the script to look at the full code if it would help.
View Replies !
Http Auth + Php
Is it possible to get PHP to pass a login/password to an htaccess protected dir? This is to make a loginform for a page that resides in a protected dir. I want to avoid the normal login dialog the browser uses, so I amongst other things can give the user a few choices when logging in.
View Replies !
Http Or Www Replace
I wanted to know how to replace a URL when it is outputted. I tried to use the following: $output = ereg_replace('http://([[:graph:]]+) ', '[<a href="http://1">link</a>] ', $output); $output = ereg_replace('www.([[:graph:]]+) ', '[<a href="http://1">link</a>] ', $output); but it doesnt work properly, so i want one that replaces the URL when http://www.?.com or www.?.com and replaces with [<a href=http://www.111.com">link</a>] Would i have to use two of these but just in a different way or use one or even use a whole different function.
View Replies !
HTTP Authentification
I need to download an XML file from a website, but everytime I go to the URL, I need to authenticate(basic) via the http header. What kind of text should I send to do it via php?
View Replies !
HTTP Variable -
Say I type in an address in my location bar. I press enter and go to the specified page, say http://www.foo.com/foo-foo.php. HTTP_REFERER returns the referring page - which is very close to what I need, but it only works where the user clicked a link to get to foo-foo.php. If user manally enters the address, HTTP_REFERER is empty. Is there a way to get manually typed in urls? REQUEST_URI returns the actual page the user is on. For my application REQUEST_URI isn't what I need. I'm building an error page and I want a report of any pages users are trying to reach that are not found.
View Replies !
Http-get And Headers
I am looking to write code that can read a file from an http address (for example: http://www.somesite.com/document.xml) and check it for any changes (an updated state) then download it if it is a newer version. I have seen references to the http-get functionality of PHP , but can't find any examples or tutorials. Apparently I can check some http headers to determine whether the document is new or not? Can anyone direct me to some help on this issue?
View Replies !
Using A Http Proxy
I've been trying to get PHP to access all http data via a proxy server - this is the only way I can get anything from port 80 on my Uni connection. I've checked phpinfo() and the environmental variable http_proxy seems to be set, but fopen("http://...") isn't working... I really need to make this work.
View Replies !
Doing An Http Post
For the benefit of others, I want to show how to do an HTTP POST request using fsockopen(). I banged my head against a wall for two days trying to figure this out. I even went to http://php.net/ to find out how to do this, but it didn't help because my mind automagically converted the "Content-Length" header into "Length." I even went to find out the specific protocol for HTTP POSTs, but I didn't find it there. RFC 2616 (HTTP) does not give the exact format for POST requests. Question: Where is the format for POST requests defined? ---------------- send_post.php --------------- <?php // file: send_post.php error_reporting(E_ALL & ~E_NOTICE); $eol = " "; $errno = 0; $errstr = '' $data = 'username=george&password=i81bpz' $fid = fsockopen('localhost', 8080, &$errno, &$errstr, 30); if ($fid) { fputs ($fid, "POST /post/show_post.php HTTP/1.1$eol"); fputs ($fid, "HOST: localhost$eol"); fputs ($fid, "Connection: close$eol"); fputs ($fid, "Content-Type: application/x-www-form-urlencoded$eol"); // Use 'Content-Length' NOT 'Length' ! fputs ($fid, 'Content-Length: ' . strlen($data) . $eol); fputs ($fid, $eol); fputs ($fid, $data); fputs ($fid, $eol); fpassthru($fid); } ?> ------------- show_post.php ----------------- <?php // file: show_post.php error_reporting(E_ALL & ~E_NOTICE); echo "<pre>"; echo "------------ POST VARIABLES ----------"; print_r($HTTP_POST_VARS); echo "------------ SERVER VARIABLES ----------"; print_r($HTTP_SERVER_VARS); echo "</pre>"; ?>
View Replies !
HTTP Expire
I want to cashe database driven forum, but SESSION is used for passing userID. When I use code below offline browsing is ok, but session variable is difrent on cashed pages. Some pages stored gost id some admin. How can i solve this. <?php ob_start(); session_cache_limiter('private'); header("Cache-control: private"); header("Content-Type: text/plain"); header("Pragma: public"); session_start(); ?> <!-- SADR®AJ --> <?php ob_end_flush(); ?>
View Replies !
Http Referer?
I'm bulding this web site and I do not want other to link to my pages. I can use on every sinle page the http_referer to detect who's the referer and decide if I have to give access or not... but isn't there a better way of doing this instead of putting a piece of code on very single page ?
View Replies !
FsockOpen With Http 1.1
I have the following code that needs to be transferred into HTTP 1.1 I am running on windows and wondered if this is an easy undertaking and what to beware of from user experience. PHP Code:
View Replies !
Include Using Http://
i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to include a file. It isnt returning anything or connecting to the database (which is what it is supposed to be doing). any ideas? if i put in the path to the file it works, but I need it to do it over http the rest of the code is being run over a symbolic link and I need different connections per website.
View Replies !
Http-Download
I want to load a file from a foreign server down in a certain directory of my webserver. How ? It's no ftp-download.
View Replies !
Getting Files Over Ftp/http
Before I go on a mad quest to try to code some pages, I think it's probably prutent to ask something. If I were to pass a php page either an ftp or http address of an image file (assuming it had a username and password coded in), would I be able to make it go and get that file and save it in a folder local to that page?
View Replies !
Http Headers
[x-posted here and there] Excuse me if this is OT here. I'm trying to find out what would happen if I append my: Content-Type: application/x-javascript Content-Length: nnn <javascript data> To an http answer in transit. 1) Does appending such a thing to an http answer which already has it's own content-type and length headers and data, is allowed ? 2) How would a typical browser understand it ? Would it just ignore it ? If the answer to (1) is "no": what would you suggest to do ? I've thought of capturing the stream, and creating multi-part. The first part would be the captured one, and the second - the data I want to append. Does it seem as a good scheme to you ?
View Replies !
Run A Php In The Background Using Http
i have a script (script1) which needs to call another script (script2). It should not wait for the answer, so script2 should run in the background. I really need to call the php script using: http://urlof myscript/script2.php I don't want to use it as a cgi and use CLI. I did a test with fsockopen and curl and a timeout of 10 seconds and call http://urlof myscript/script1.php from my browser: Script1 stops after 10 seconds => OK Script2 has been called by script1 and continue to run in the background =>OK After 60 seconds Script2 is killed by php!! => KO :( The script is working fine if i call http://urlof myscript/script2.php from my browser. It needs around 120 seconds to finish. Why is it stopping after 60 seconds when I use fsockopen and call it from script1? Here is the script in SCRIPT1: $fp = fsockopen("$host", 80, $errno, $errstr, 30); stream_set_timeout($fp,10); if (!$fp) { echo "$errstr ($errno)<br /> "; } else { $out = "GET $path HTTP/1.1 "; $out .= "Host: $host "; $out .= "Connection: Close "; fwrite($fp, $out); $status = socket_get_status($fp); while (!feof($fp) && !$status['timed_out']) { echo fgets($fp, 128); $status = socket_get_status($fp); } fclose($fp); } I have added this in SCRIPT2: ignore_user_abort(FALSE); // becareful, FALSE really means it should ignore user abort !!! set_time_limit (120); ini_set("max_input_time",120); ini_set("max_execution_time",120); Do you have any idea?
View Replies !
Http To Https
i have a page which is a application form and should be in https. it also works with http. is there any script to redirect the page to https when the request is from http?... the server is IIS. i want only that page to be in https and dont want the whole site in https.
View Replies !
Get The 'http://' Section From The Url Bar..
I'm sure this is really simple, but I'm trying to get the full url from the address bar. I'm using this: $url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];which works fine except I'm wanting to check whether the page is 'http://', 'https://' or even 'ftp://' and add that to the beginning. At the moment I get something like: www.mydomain.com/folder/index.php
View Replies !
HTTP Header
I've got a question concerning the headers sent by the client accessing your page. I have found there are several variables accessible in PHP: $_SERVER['REMOTE_ADDR'] (which should not be determined by any HTTP headers, but by the web server reading the TCP/IP headers, right?) $_SERVER['HTTP_VIA'] (which will be filled if there is a transparent proxy) the above are pretty clear and cause no problems. But when you continue to search for headers that can possibly be sent by a client (may it be a proxy or not), it's getting very confusing: $_SERVER['HTTP_X_FORWARDED_FOR'] $_SERVER['HTTP_CLIENT_IP'] $_SERVER['HTTP_PROXY_CONNECTION'] $_SERVER['FORWARDED_FOR'] $_SERVER['X_FORWARDED_FOR'] $_SERVER['X_HTTP_FORWARDED_FOR'] $_SERVER['HTTP_FORWARDED'] I mean, they all seem to denote the SAME thing. Why use SEVEN different headers for that? Were the guys who wrote the RFCs bored? Why confuse people with so much possible headers, when it could be in ONE SINGLE header? Apparently this is not a PHP problem, since PHP just fills these variables by reading the HTTP header lines (X-Forwarded-for: , X-Forwarded: , ...) sent by the client. I have googled for all of those, but opinions seem to differ on what header line should be taken into account and what header line shouldn't. So, 1) Why are there so many possible headers? Are some of them obsolete? 2) What is the difference between those headers with a 'X' and those which lack the 'X'? 3) What is the difference between "FORWARDED_FOR" and just "FORWARDED"?
View Replies !
HTTP 500 Error
I have two web site with PHP for my Assignment. Both of them have login page Site 1 is running fine. But when i run site 2 and try to use login page and submit it shows me a error 500 page I m confused why in the same server one site working fine and another one is not working? [/color]
View Replies !
Http Authenication
I was using this small script to prompt for password on some password protected folders. It was working great but I've moved servers and now the script hangs on the line "if(defined('USER_AUTHENTICATED') && USER_AUTHENTICATED){" It doesn't like the "USER_AUTHENTICATED" but if I take it out it shows the page while it is prompting for password which I don't want. What could be causing this, is USER_AUTHENTICATED a global variable or something? Code:
View Replies !
PHP And HTTP Auth.
I have been trying to set up a script for HTTP Auth where a user can fill in a form, with a username and password and it logs the user in via .htaccess and http auth. I have found tutorials online about how to check if someone is logged in or not,,, but thats not what im looking for... Anyone any idea how this can be done?
View Replies !
HTTP Authentication
I spent quite some time comming up with a suitable, yet basic HTTP Authentication script. I think it works for what I am doing, yet would like some opinions on it, the bads, the worse's and sure, even the goods ;0) I have a logon for the directory call "widgets". This directory contains semi-sensitive materials, that the general public doesn't need to see. So I have a list of files here: index.php -- where thbase of my authentication is include.inc -- an include file, hidden way high up in my server root, above the web root and accessible only with administrative privileges. This file contains my usernames and passwords in comma seperated values ie John,hispass. and the rest of my files widgets1.php widgets2.php widgets3.php widgets4.php widgets5.php .. etc index.php contains the following code: ...........
View Replies !
HTTP Vs. FTP Upload
I have to implement a file upload for a client who's customers should be able to upload very large files (up to 500 MB). Up to now I always used the regular http upload, but also always experienced some problems with uploading big files (time outs,max_file_size, httpd.conf parameters etc.) Since I want to make the upload as reliable as possible (and to avoid to make the customers having to start the upload over and over), I am wondering if ftp upload would be a better choice and if it would be more reliable than http.
View Replies !
PHP.ini In Subdirectory Causes HTTP 400
I'm currently working with a new hosting company using Windows IIS running PHP 4.3.6. I am trying to customize the php.ini local to my web domain only. I have downloaded the recommended PHP 4-style php-dist.ini, renamed it to 'php.ini' and put it in the root of my web directory. However, any browser request returns an HTTP 400 error. I've gone through the settings thoroughly and don't understand what could be causing this to break. Is there some special step I'm missing? I don't have access to the default php.ini in WINNT, but I made sure to get the critical info (include paths, etc) by running phpinfo() first and set the variables the same in my ini file.
View Replies !
HTTP Post With *
If I have a field which I am POSTing, and that field is, say, a mathematical expression such as: 2*8 must I escap the * somehow? what if it is something like: 8 / 2 How can I escape these String values when I POST them, such that the subsequent page can retrive the original expression?
View Replies !
HTTP 406 Error - WTF?
So I made a test page to write some code. On ANYTHING I upload, I get a 406 error. All of my pages created previously work fine, but anything new gives a HTTP 406 error. Code:
View Replies !
Replacing Http://
got a shoutbox script I've made with some help and it has an excisting URI option. When a URI is entered in the form it will make a link of the posters nick, <a href="http://www.example.net">Poster's nick</a>. But when nothing is entered the default http:// will be entered into the database making a <a href="http://">Poster's nick</a> link. So what I want is some sort of easy function that checks if the string "http://" is there in this exact state (so a full URI has to pass this check), if it is, it will replace it with an empty string making no link.
View Replies !
HTTP Request Through SSO
We have a web application that's protected by Siteminder SSO. I'd like to do an fopen to it from my PHP script. How do I have my script "log on" through SSO so that it do the fopen?
View Replies !
HTTP/Request
I have been told by the API developer to use PEAR. Never used this before but looks like a function within PHP. Code:
View Replies !
S/MIME Over HTTP
The thing im trying to do is transport encrypted data to a client browser (which will have the private key certificate in PKCS12 format). I want to be able to be sure that the client is who it says it is, and that this data is transferred encrypted with only the client having the private key being able to decrypt it. The problem is i dont have access to httpd.conf in this case, which would have been a posible solution. My next idea was therefore to use S/MIME over http where in the client browser IE it has a installed certificate in PKCS12 format (thus having private key access). I believe IE has support for S/MIME, and i guess this needs some sort of programming of the http headers sent (through headers() function).
View Replies !
HTTP Referer
I'm righting a little script that will check the HTTP Referer, and if it equals such and such then to do nothing (ie let the user remain on that page.) If it doesn't equal that then it's gonna redirect them to another page. Basically what I need is how to say "do nothing" in PHP. Would it go something like this?
View Replies !
Http Url Call
at work i have to develop this user authentication. they have provided me with a link that make REST method calls to user/pass and if correct then dumps true to the page or some false message otherwise. for example: http://www.example.com/auth?user=admin&pass=password my problem is that i don't know how to make html reqeust with php and google didn't help since i am not searching with correct key words.
View Replies !
|