PHP - Adjust Htaccess File From Php
I need to adjust mod rewrites from an admin panel. Any ideas on how to do this?
Similar TutorialsHello can anyone help with my code, it bombs out if I dont add in a file for attachment but i want to be able to add to the database with just comments (sometimes without a file) Any help appreciated!!! $timestamp = time(); $tbl_name="guestbook"; // Table name $email = $_REQUEST["email"]; $name = $_REQUEST["name"]; $comment = $_REQUEST["comment"]; $datetime = date("dmy"); $uploaddir = "upload/"; $filename = $timestamp.$file['file']['name']; $filename = strtolower($filename); $final_location = "$uploaddir$filename"; $pathinfo = pathinfo($_FILES['userfile1']['name']); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 2000000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $filename . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists($final_location)) { echo $filename . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], $final_location); echo "Stored in: " . $final_location . "<br>"; mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $sql="INSERT INTO $tbl_name(name, email, comment, datetime, upload)VALUES('$name', '$email', '$comment', '$datetime', '$final_location')"; $result=mysql_query($sql); } } //} else { echo "Invalid file"; } if($result){ echo "Successful added update to the Board"; echo "<BR>"; echo "<a href='HomePage4.php'>View Bulletin Board</a>"; } else { echo "ERROR"; } mysql_close(); ?> http://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, This topic has been moved to PHP Installation & Configuration. http://www.phpfreaks.com/forums/index.php?topic=310649.0 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! 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} Hi 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. Hello: Hoping someone can help me figure this out... I am resizing a photo/thumbnails with GD (I think that's the correct term) upon uploading. Works fine but the one thing I can't figure out is how to scale the height proportionate with the width. Meaning, I have the width set to 690px, and the height set to 500px. It is making the images look squished. What I would like to do is have a set width (like 690px), but have the height scale down proportionalety. Or, can I just remove the height (although I tried that and it did not work). This is the code: Code: [Select] // Let's get the Thumbnail size $size = GetImageSize( $images_dir."/".$filename ); if($size[0] > $size[1]) //{ //$thumbnail_width = 100; //$thumbnail_height = (int)(100 * $size[1] / $size[0]); //} //else //{ //$thumbnail_width = (int)(100 * $size[0] / $size[1]); //$thumbnail_height = 100; //} { //$thumbnail_width = 690; //$thumbnail_height = (int)(500 * $size[1] / $size[0]); $old_width = $size[0]; $old_height = $size[1]; $thumbnail_width = 690; $thumbnail_height = ($old_height * $thumbnail_width / $old_width); } else { $thumbnail_width = (int)(690 * $size[0] / $size[1]); $thumbnail_height = 500; } // Build Thumbnail with GD 1.x.x, you can use the other described methods too $function_suffix = $gd_function_suffix[$filetype]; $function_to_read = "ImageCreateFrom".$function_suffix; $function_to_write = "Image".$function_suffix; // Read the source file $source_handle = $function_to_read ( $images_dir."/".$filename ); if($source_handle) { // Let's create an blank image for the thumbnail //$destination_handle = ImageCreate ( $thumbnail_width, $thumbnail_height ); $destination_handle = imagecreatetruecolor( $thumbnail_width, $thumbnail_height ); // Now we resize it ImageCopyResized( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1] ); } // Let's save the thumbnail $function_to_write( $destination_handle, $images_dir."/tb_".$filename ); ImageDestroy($destination_handle ); // $result_final .= "<img src='".$images_dir. "/tb_".$filename."' style='margin-right: 20px; width: 100px;' />"; Anyone have any ideas on this? Thanks much. hello dear php-experts i run opensuse 13-2 and i am very very happy the time does not get displayed correct. it falls back to UTC all day. What can i do. i have had look at the documents here https://en.opensuse....uring_the_clock https://tr.opensuse....T_Date_and_Time how to set up correct to the local time - note i live in GERMANY near francfurt Code: [Select] <?php if(date('w') == 0) $str = 'today'; else $str = 'last sunday'; $timestamp = strtotime($str); //echo $timestamp; echo "<img src='brn_masthead.gif' width='500' /><br /><table border='1'><tr>"; echo "<tr><td align='center' width='140'><b>Sunday</b></td><td align='center' width='140'><b>Monday</b></td><td align='center' width='140'><b>Tuesday</b></td><td align='center' width='140'><b>Wednesday</b></td> <td align='center' width='140'><b>Thursday</b></td><td align='center' width='140'><b>Friday</b></td><td align='center' width='140'><b>Saturday</b></td></tr><tr>"; $j = 0; for($i = 0; $i < 14; $i++) { $thisdate = date('Y-m-d', $timestamp + ($i * (60 * 60 * 24))); ?> I've looked into mktime and checked the manual, but can't find anything that seems to work inside the loop. Thanks! Hey guys I have a small issue, i have an upload that resizes the image into thumbnail by max width and ratios the width based on that. Here is my code
What I am wanting to do is instead upload the image with a max height and ratio the width proportionally. What variables do I have to reverse? 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, 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? 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; } } }
This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=356252.0 Hi, I have the htaccess file with the below details in it.
<FilesMatch ".(py|exe|php)$">
And when i modify the file and save it, i get the the message "successfully saved". But when i refresh the page , again the file loads the old content as before. I dont know the reason, and additionally when i delete the file, it automatically reappears. ( this is not a wordpress website) Hi Guys, I no its only a partial PHP question but its still related to PHP... I have a URL .com/sites/0.php?Ter=144 and it takes you to a page and loads details with the id (ter) equalling 144 and displays all of 144's information... normal PHP stuff However I want to be able to put a Rewrite rule using a .htaccess (unless there is a better method!?) to get search engine frienly results. However I dont want the user to type .com/144 to bring up the Leeds branch. I want them to type .com/leeds and it bring up 144 (Leeds Branch). BranchName is the field I use for the branch name in my MySQL table. Is this possible? Also when I enter .com/sites/0.php?BranchName=Leeds that doesnt work either... Cheers, Sam |