Monday, July 18, 2016

.htaccess Redirection Rule

This .htaccess file will redirect http://example.com/folder1/ to http://example.com/folder2/. Choose this version if you don't have the same file structure in both directories:
Filename: .htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder1.*$ http://example.com/folder2/ [R=301,L]
  • This .htaccess file will redirect http://example.com/folder1/ to plain http://example.com/. Choose this version if you want people redirected to your home page, not whatever individual page in the old folder they originally requested:
Filename: .htaccess.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder1.*$ http://example.com/ [R=301,L]
  • This .htaccess file will redirect http://example.com/folder1/file.html tohttp://example.com/folder2/file.html. Choose this version if your content is duplicated in both directories:
File name: .htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder1/(.*)$ http://gs.mt-example.com/folder2/$1 [R=301,L]

Test

Upload this file to folder2 (if you followed the first or third example) or your html folder (if you followed the second example) with FTP:
Filename: index.html
<html>
<body>
Mod_rewrite is working!
</body>
</html>
Then, if you followed the first or second example, visit http://example.com/folder1/ in your browser. You should see the URL change to http://example.com/folder2/ orhttp://example.com/ and the test page content.
If you followed the third example, visit http://example.com/folder1/index.html. You should be redirected to http://example.com/folder2/index.html and see the test page content.

Thursday, June 23, 2016

Tuesday, June 7, 2016

How to remove symbol � ? PHP Include and accents (They show up as �)

That happens if the browser thinks your using another encoding than you actually use.
try to add the following in your php file before any html is printed:

header ('Content-type: text/html; charset=utf-8');
// or
header ('Content-type: text/html; charset=iso8859-15');

and add

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- or -->
<meta http-equiv="Content-Type" content="text/html; charset=ISO8859-15" />

between the <head></head> tags

UPDATE: just saw your update with the file. you need to add header ('Content-type: text/html; charset=utf-8');

Thursday, November 5, 2015

How to check given array is in which order..

    #include<stdio.h>
    #include<conio.h>
    #include<string.h>
    int main()
    {
    //int a[10]={2,5,1,7,0,10,145,14,15,9};
    int a[10]={1,2,3,4,5,6,7,8,9,10};
    int tem,i=0,j,isTRUE=0;
    for(j=0; j<10; j++)
    {
    if(a[j]<a[j+1])
    {
    isTRUE=1;
    break;
    }
    isTRUE=0;
    }
    if(isTRUE)
    printf("inorder\n");
    else
    printf("ASEorder\n");
    getch();
    return 0;
    }

How to find Length of string without using function?

$count = 0;
for ($i = 0; $i < 1000000; $i++) {
     if(isset($temp[$i]))  
        $count++;
     else
         break;
}
print_r($count);

****************************************************************
Another simplified version

$count = 0;
for ($i = 0; TRUE; $i++) {
     if(isset($temp[$i]))
        $count++;
     else
         break;
}
print_r($count);


Displaying MYSQL database table into PHP table

I have set up a MYSQL database and added a table with some data. I want to display this in a table in PHP that is 3 wide, like this:
<table width="100" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>item1</td>
    <td>item2</td>
    <td>item3</td>
  </tr>
  <tr>
    <td>item4</td>
    <td>item5</td>
    <td>item6</td>
  </tr>
  <tr>
    <td>item7</td>
    <td>item8</td>
    <td>item9</td>
  </tr>
</table>

and so on...
Now, I have been using this PHP:
CODE
<?php
//connect to the server
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

//connect to the database
mysql_select_db(product_index);

//query the database
$query = mysql_query("SELECT * FROM products WHERE type = 'bracelets'");

//fetch the results / convert results into an array

        WHILE($rows = mysql_fetch_array($query)):
       
            $product_name = $rows['product_name'];
            $id = $rows['id'];
            $description = $rows['description'];
            $price = $rows['price'];
            $image_large = $rows['image_large'];
            $image_thumb = $rows['image_thumb'];
            $page_link = $rows['page_link'];
            $purchase_link = $rows['purchase_link'];
       
        echo "$product_name<br>$description<br>$price<br>$image_large<br>$image_thumb<br>$page_link<br>$purchase_link<br><br><br>";
       
        endwhile;
?>

Wednesday, October 28, 2015

how to write css in different browser..Prevent Bootstrap Modal from disappearing when clicking outside or pressing escape?

1.Prevent Bootstrap Modal from disappearing when clicking outside or pressing escape?

If using javascript then:

$('#myModal').modal({
    backdrop: 'static',
    keyboard: false
})
and if HTML:
<a data-controls-modal="your_div_id" data-backdrop="static" data-keyboard="false" href="#">

**************************************************************************************************
2.how to find ip address in php
<?php echo $_SERVER["REMOTE_ADDR"];     ?>
********************************************************
3.how to get base url
<?php echo getcwd(); ?>
********************************************************
4. how to write css in different browser..
.safari { /* Safari only */ }
.mac { /* Mac only */ }
.safari.mac { /* Safari Mac */ }
html:not(.safari) { /* All browsers except for Safari */ }
html:not(.safari.mac) { /* All browsers except for Safari Mac */ }
**************************************************************************