PHP - .htaccess File - Causing Loops?
Hello all
Was hoping someone could help. I have a .htaccess file that contains the following:
RewriteEngine On RewriteRule ^sites/([a-z0-9]+)/?$ sites.php?letter=$1 [NC,L,QSA] RewriteRule ^network-devices/([a-z0-9]+)/?$ network-devices.php?letter=$1 [NC,L,QSA] RewriteRule ^site/([0-9]+)/?$ site.php?site_id=$1 [NC,L] RewriteRule ^network-device/([0-9]+)/?$ network-device.php?device_id=$1 [NC,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php?%{QUERY_STRING} Similar Tutorialshttp://www.myurl.com.au/newlook/hotel_list.php?cntry=AU&cntryname=Australia&city=Brisbane&checkin=06/12/2014&checkout=06/13/2014&room=1&guest=2 to http://www.myurl.com.au/newlook/Australia/Brisbane baring in mind that the country and city will changeI am trying to find out if it is possible to rewrite my urls in htaccess file from hi, can you please tell me what is .htaccess file ? thanks in advance shiva Hi guys. I have a record shop online. The following URL example shows the product info page without a problem: http://www.mysite.com/tp/html/product/33/record1.html Im using an .htaccess file as follows:
RewriteEngine On My problem is that the sound files are in a different folder on the server : www.mysite.com/sf/soundfile.mp3 The mp3 sound files are not found or shown on the detail.page as they are in a different folder which doesnt have a rule associated with it. It doesnt need one as the mp3 file doesnt need SEO referencing. How do i tell the .htaccess file to look in the sf folder to find the mp3 files on my detail.php page? thanks! I need to adjust mod rewrites from an admin panel. Any ideas on how to do this? This topic has been moved to PHP Installation & Configuration. http://www.phpfreaks.com/forums/index.php?topic=310649.0 Hi guys, Hi all, I've been running into some issues trying to stream .mp3 files, specifically Safari/Flash... Firefox works great. I'm about to throw in the towel on this one and try another streaming solution, so I thought I'd reach out and connect with the PHP pros here before trying something else. Basically, the PHP streamer takes a track guid variable and token variable(MD5), looks up the field in the DB, gets the url and then proceeds to stream the file with no caching, and keeping the URL hidden from the user so they can't download it. The token variable is there to assure that the url is only used once. Once it is, the script will not allow the stream if the token/track guid combo already exists in the DB. The problem with the looping is that once that token has been used it won't stream the track, which is how it's suppose to work, sans looping. I've put an MYSQL INSERT into the code to verify that it does loop.. usually I see 3- :wtf:5 consecutive entries in the DB for that token. So Firefox does not do this.. and I gather it's something to do with how the client streams with the "readfile" function. Pasted below is some code to show the headers and the readfile function I am using. I can post the rest of the script if need be. //$path and $tokenApproved are variables i set earlier in the script date_default_timezone_set('GMT'); $date = date(DATE_RFC822); $filesize = ffilesize($path); $shortlen = $filesize - 1; //ffilesize() is a custom filesize function if($tokenApproved) { header("Content-type: audio/mpeg"); header("Content-Length: $filesize"); header('Content-Range: bytes 0-'.$shortlen.'/'.$filesize); header("Expires: $date"); header('Content-Disposition: filename="eztunesaudio.mp3"'); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); readfile($path); } //eztunesaudio.mp3 is just a default name I give the stream Good morning folks, I'm having an obscure issue with previously sent headers. I have an add_category.php for the admin backend of an app I'm working on. It was working fine until I added a Post.php class, but the Post.php class doesn't even interact with add_categories.php outside the initialization file. When I use this file to add a category I get the normal Quote
Warning: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/qcic/assets/class/Post.php:94) in /opt/lampp/htdocs/qcic/admin/category.php on line 6
Like I said, this was working fine until I added the Post.php class. But the only time that they even come close to interacting is in the initializations.php which I put at the top of each of the pages and looks like this -> <?php require("../load.php"); require("../assets/class/User.php"); require("../assets/class/Category.php"); require("../assets/class/Post.php"); $user = $user_obj->getUsername(); $role = $user_obj->getRole(); $cat_obj = new Category($conn, $user); $post_obj = new Post($conn, $user); The relevant code for the add_category.php is -> <?php require("assets/initializations.php"); if(isset($_POST['add_cat'])) { $cat_obj->addCategory($_POST['cat_title']); header("Location: category.php?message=category-added"); exit; } ?> After some research I've altered this a bit to this -> <?php require("assets/initializations.php"); if(isset($_POST['add_cat'])) { $cat_obj->addCategory($_POST['cat_title']); if(!headers_sent()) { header("Location: category.php?message=category-added"); exit; } else { var_dump(headers_list()); } } ?> Which returns this -> Quotearray(5) { [0]=> string(23) "X-Powered-By: PHP/8.0.3" [1]=> string(38) "Expires: Thu, 19 Nov 1981 08:52:00 GMT" [2]=> string(50) "Cache-Control: no-store, no-cache, must-revalidate" [3]=> string(16) "Pragma: no-cache" [4]=> string(38) "Content-type: text/html; charset=UTF-8" } I have no idea where those are coming from or why they're coming at all and that date is a long time ago. Some of it looks familiar, some I've never seen before. I haven't come across a remedy that works yet though. Any suggestions?
EDIT: typo Edited Monday at 03:52 PM by TechnoDiverHi All
I have directory fiole like this
my_website/flash/file.html
I want to disable redirect to file.html via URL.
I have create .htpasswd and create .htaccess in flash folder with this code
# the auth block
AuthName "Please login."
AuthGroupFile /dev/null
AuthType Basic
AuthUserFile C:/xampp/htdocs/.htpasswd
# Here is where we allow/deny
Order Deny,Allow
Satisfy any
Deny from all
Require valid-user
Allow from env=noauth
Satisfy any
its Work, people cant redirect via change the URL but it also occurs with valid user via Login Session.
How to Set .htaccess file for bypass the .htpasswd via login Session user ?
How to solve it?
thanks
I want to remove the file extension - I have done that.
I want to remove the trailing slash. - I have done that
But I cannot for the life of me get the the regular page to display instead of the folder which show a tree of files within it.
site.com/website-tips.php site.com/website-tips/increase speed.php The extension drops off and the trailing slash too but when I navgate back through the vreadcrumb to website-tips (without php in html code) it gives me the folder and shows the file tree (files within website tips folder) How would I solve this? right now if I access the website-tips.php file, it shows the directory and its interior pages Pls hlp out. The code below is working in relation to what I expect it to do however it is allow causing this error on top of the form everytime... Notice: Undefined index: submit in C:\wamp\www\protek\register.php on line 130 Notice: Undefined index: fullname in C:\wamp\www\protek\register.php on line 133 Notice: Undefined index: email in C:\wamp\www\protek\register.php on line 134 Notice: Undefined index: username in C:\wamp\www\protek\register.php on line 135 Notice: Undefined index: password in C:\wamp\www\protek\register.php on line 137 Notice: Undefined index: password2 in C:\wamp\www\protek\register.php on line 138 The full code being used is > <?php //check for submit $submit =$_POST['submit']; //gather POST variable $fullname =strip_tags($_POST['fullname']); $email =strip_tags($_POST['email']); $username =strip_tags($_POST['username']); $password =strip_tags($_POST['password']); $password2 =strip_tags($_POST['password2']); if ($submit) { //check that fields were filled in if ($fullname&&$email&&$username&&$password&&$password2) { //now we can encrypt our password to md5 $password = md5($password); $password2 = md5($password2); //were done seeting md5 //check to see if our two password fields match if ($password==$password2) { //check to see if the password is greateer than 25 but less than 6 if (strlen($password)>25||strlen($password)<6) { //if it is then echo "<font color='red'>Your password must be between 6-25 characters</font>"; } //otherwise register the user else { echo "Success"; } } //otherwise if passwords don't match else echo "<font color='red'>The passwords you entered do not match</font>"; //end of checking password } else echo "<font color='red'>Please enter all fields!</font>"; } //end check for submit ?> I am having problems understanding how to sanitize my form data so it is safe to INSERT. If I use this code... Quote $trimmed = array_map('trim', $_POST); $body = mysqli_real_escape_string($dbc, $trimmed['body']); And I enter into my form... Quote O'Reilly's book Then I see this in phpMyAdmin... Quote O\'Reilly\'s book --------- If I use this code... Quote $trimmed = array_map('trim', $_POST); $body = $trimmed['body']; And I enter into my form... Quote O'Reilly's book Then I see this in phpMyAdmin... Quote O'Reilly's book Why the strange behavior?? Debbie So I have an webapp which has a built in proxy checker. However because I didn't write the code I am kind of confused on whats going on. I have a small amount of knowledge on php been looking all over the net to find a solution. So this file called (proxy_check.php) keeps causing my index.php to show the 404 designed page. The file is required in the index.php file. I believe its something to do with the $reponse variable. Please help <?php # Visitor proxy check snippet $v_ip = $_SERVER['REMOTE_ADDR']; $arContext['http']['timeout'] = 10; $context = stream_context_create($arContext); $response = file_get_contents('http://www.shroomery.org/ythan/proxycheck.php?ip='.$v_ip, 0, $context); if ('Y' === $response) { echo "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'> <head> <title> The page you were looking for doesn't exist (THIS BUG)</title> <style type='text/css'> body { background-color: #efefef; color: #333; font-family: Georgia,Palatino,'Book Antiqua',serif;padding:0;margin:0;text-align:center; } p {font-style:italic;} div.dialog { width: 490px; margin: 4em auto 0 auto; } img { border:none; } </style> </head> <body> <div class='dialog'> <a><img src='assets/img/404.png'></a> <p>It looks like that page you were looking has been mislaid, sorry.</p> </div> </body> </html>"; die(); }
Hi There, I have an application that uses a Flash front end. The user fills out a card. The variables of that card are stored in an SQL Database and the recipient gets an email with a unique url to retrieve the card. The problem I am faced with ... is that if the user hits their ENTER key while typing their message to create line breaks.. the line breaks are causing the SWFOBJECT Flash Embed to break. The SWFOBJECT embed code looks like this Quote var flashvars = { yname: "<?php print "$yname";?>", yemail: "<?php print "$yemail";?>", fname: "<?php print "$fname";?>", femail: "<?php print "$femail";?>", greeting: "<?php print "$greeting";?>", message: "<?php print "$message";?>", fullname:"<?php print "$fullname";?>" }; The results look like this when data has been filled out Quote <script type="text/javascript"> var params = { quality: "high", //scale: "ExactFit", wmode: "transparent", menu: "false", allowfullscreen: "true", allowscriptaccess: "always", bgcolor: "#014872" }; var flashvars = { yname: "Jonathon", yemail: "name@email.com", fname: "TEST", femail: "jname@email.com", greeting: "TESTING", message: "Test Test Test", fullname:"" }; You can see the line breaks whe Test Test Test Was typed. Any ideas how to fix this ? Hi can someone help me i have this .htaccess code
Supposed i have RewriteRule ^([a-zA-Z0-9-z\-]+)/([^.]+)/([a-zA-Z0-9-z\-]+)$ index.php?Active=$1&PostID=$2&PostName=$3 [L]
this line wont work ##RewriteRule ^([a-zA-Z0-9-z\-]+)/([^.]+)$ index.php?Active=$1&PostCell=$2 [L] so i commented it
i need to make them both work for pretty urls Options -Indexes Options +FollowSymLinks -MultiViews RewriteEngine On ErrorDocument 404 /404.html ErrorDocument 401 /404.html ErrorDocument 403 /404.html ErrorDocument 404 /404.html ErrorDocument 500 /404.html RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} /(.*)/$ RewriteRule ^ /%1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{DOCUMENT_ROOT}/$1 -f RewriteRule ^[^/]+/([^.]+\.(?:js|css|jpe?g|png|gif))$ /$1 [L,R=301,NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z0-9-z\-]+)/?$ index.php?Active=$1 [L] ##RewriteRule ^([a-zA-Z0-9-z\-]+)/([^.]+)$ index.php?Active=$1&PostCell=$2 [L] RewriteRule ^([a-zA-Z0-9-z\-]+)/([^.]+)/([a-zA-Z0-9-z\-]+)$ index.php?Active=$1&PostID=$2&PostName=$3 [L] Thank you in advanced. Edited May 27, 2020 by azumicaHi people i have this link http://localhost/ViewCategory/PHP my problem is everytime i put / from PHP/ it will redirect me to Access forbiden andd return me this http://localhost/C:/xampp/htdocs/index.php?Active=ViewCategory&PostCategory=PHP/
how to fix it this is how my htaccess code
Options -Indexes RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{DOCUMENT_ROOT}/$1 -f RewriteRule ^[^/]+/([^.]+\.(?:js|css|jpe?g|png|gif))$ /$1 [L,R=301,NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z0-9-z\-]+)/?$ index.php?Active=$1 [L] RewriteRule ^([a-zA-Z0-9-z\-]+)/([^.]+)$ index.php?Active=$1&PostCategory=$2 [L]
Hi how can I make this URL clean http://localhost/?Active=View&PostCategory=1 i want to remove the ?,&, = make them into / this is the php code that manipulate the link <?php Class ControlURL{ public static $_page = "Active"; public static $_folder = Web_Body; public static $_params = array(); public static function cPage() { if(isset($_GET[self::$_page])){ return $_GET[self::$_page]; }else{ return 'index'; } } public static function getPage() { $page = self::$_folder.DS.self::cPage().".php"; $error = self::$_folder.DS."error.php"; if(is_file($page)){ return $page; }else{ return $error; } } }
Hi, Was woudering if someone could help? I would like to stop people accessing a folder (web directory) on my domain using the .htaccess. However the folder contains scripts in it that i use thererfore a redirect away from that folder does not work. can you help? i have been given this task in in uni. i was wondering it some one would be so kind to help me with it. all i have so far is this <?php for($x=1; $x<=3; $x=$x+1) { print "$x <br>"; } if ($x== "A") { } ?> the task is below Generate a number between 1 & 3 If 1 then assign A, If 2 then assign B, If 3 then assign C Add to a wordstring (using string concatenation with .) We need 3 letters generated to give a 3 letter word For loop (3) Generate a number between 1 & 3 If 1 then assign A, If 2 then assign B, If 3 then assign C Add to a wordstring (string concatenation with .) End loop Print 3 letter word Hello everyone, I've already posted a question trying to resolve my problem, but I've changed my code so much, I figured it may be best just to post a new thread with a better explanation of what I'm trying to do. Anyway, here's what I've got: I have a database with 2 tables: products and reservations. I have 3 products for now, that can be reserved for any date. I'm trying to create a page that will display all of the available products for a specific date. The user selects the date they want to check, and then the code should check their selected date and compare it with the database to display everything that is available on that date. The database looks like this: Products Table: prodid prodname 01 item 1 02 item 2 03 item 3 Reservations Table: prodid resdate 01 02/22/2012 01 02/23/2012 03 02/22/2012 Here is the code that I have now: Code: [Select] <?php $resultres = mysql_query("SELECT `prodid` FROM reservations WHERE `resdate` = '$resdate'") or die (mysql_error()); while ($rowres = mysql_fetch_row($resultres)) { $resprodid = $rowres[0]; $resultavail = mysql_query("SELECT `prodid` FROM products WHERE `prodid` != '$resprodid'") or die (mysql_error()); while ($rowavail = mysql_fetch_row($resultavail)) { $prodid = $rowavail[0]; echo $prodid; echo $proname; } } ?> When I select 02/21/2012, I get no results, where I should get all three products as a result, because none of them are reserved on this date. When I select 02/22/2012, I get a result of these products, in this order: 02, 03, 01, 02. I should get a result of ONLY 02, because this is the only product that isn't reserved for this date. When I select 02/23/2012, I get a result of 02 and 03, which in this case would be the correct return, because 01 is the only one reserved for this date. Any idea what I'm doing wrong here and how to fix it? Any help is GREATLY appreciated! |