Wednesday, May 13, 2015
Saturday, May 9, 2015
.htaccess To Redirect URLs WWW
For SEO it is important to use a set standard of how you present your domain. The most popular approach is to use the sub-domain www. Many people don't know this but http://www.domain.com is the same as http://domain.com, you will be sent to the same page but they will have different URLs.
For SEO if a search engine saw http://www.domain.com it will crawl this page, check the content and index the content. Then later if it goes and crawls http://domain.com the search engines will see the same content but on different URLs and think it is duplicate content and therefore will penalize this domain in the search engine ranking.
.htaccess To Redirect URLs
To use htaccess to redirect URL just copy and paste the snippet below and replace example.com with your domain.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
Add www With HTTP/HTTPS
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
For SEO if a search engine saw http://www.domain.com it will crawl this page, check the content and index the content. Then later if it goes and crawls http://domain.com the search engines will see the same content but on different URLs and think it is duplicate content and therefore will penalize this domain in the search engine ranking.
.htaccess To Redirect URLs
To use htaccess to redirect URL just copy and paste the snippet below and replace example.com with your domain.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
Add www With HTTP/HTTPS
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Friday, May 8, 2015
Install/update WordPress plugins without providing FTP access?
WordPress will only prompt you for your FTP connection information while
trying to install plugins or a WordPress update if it cannot write to
Now, if for some reason you do not want to rely on the automatic check for which filesystem method to use, you can define a constant,
then add this to your wp-config.php file:
define('FS_METHOD', 'direct');
Permissions explained here:
/wp-content directly.Now, if for some reason you do not want to rely on the automatic check for which filesystem method to use, you can define a constant,
'FS_METHOD' in your wp-config.php file, that is either 'direct', 'ssh', 'ftpext' or 'ftpsockets' and it will use that method. then add this to your wp-config.php file:
define('FS_METHOD', 'direct');
Permissions explained here:
Friday, April 24, 2015
Prevent accessing XAMPP, Wamp , any server localhost from another local PC by IP
use the commands given in image
1. insert : $ su
2. insert password: *******
3. # cd/etc/apache2/
4. now there is a file for edit in apache editing
5. comment the "require all granted "
6 Add "Require ip 127.0.0.1"
7 restart apache
8 # sudo service apache2 restart
Happy coding :)
nobody can check your directory by your IP
Thursday, April 23, 2015
Robomongo (v 0.8.4) connection to use localhost (127.0.0.1)
I set the Robomongo (v 0.8.4) connection to use localhost (127.0.0.1)
and port 3001. Everything else is empty/default. I am using Ubuntu 14.4 LTS .
My Robomongo settings:

My Robomongo settings:
Thursday, April 16, 2015
Ubuntu Linux: Install or Add PHP-GD To Apache Web Server
The GD Graphics Library for dynamically manipulating images. You will need to compile PHP with the GD library of image functions for this to work. However. Ubuntu (and Debian) Linux comes with the package called php5-gd.
Just type the following command to install this module:
OR
Finally, restart the Apache 2 web server, enter:
Now, you can test your php application.
How do I verify that php5-gd support loaded or not?
Type the following command at a shell prompt:
Sample outputs:
OR
OR
Just type the following command to install this module:
# apt-get install php5-gd
OR
$ sudo apt-get install php5-gd
Finally, restart the Apache 2 web server, enter:
# /etc/init.d/apache2 restart
Now, you can test your php application.
How do I verify that php5-gd support loaded or not?
Type the following command at a shell prompt:
$ php5 -m | grep -i gd
Sample outputs:
gd
OR
$ php5 -i | grep -i --color gd
OR
$ php -i | grep -i --color gd
Wednesday, April 8, 2015
PHP Question Set 01
1. Who is the father of PHP ?
Rasmus Lerdorf is known as the father of PHP.
2. What is the difference between $name and $$name?
$name is variable where as $$name is reference variable like $name=sonia and $$name=singh so $sonia value is singh.
3. What are the method available in form submitting?
GET and POST
4.How can we get the browser properties using PHP?
<?php
echo $_SERVER[‘HTTP_USER_AGENT’].”\n\n”;
$browser=get_browser(null,true);
print_r($browser);
?>
5. What Is a Session?
A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests. Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.
6. How can we register the variables into a session?
<?php
session_register($ur_session_var);
?>
7. How many ways we can pass the variable through the navigation between the pages?
Register the variable into the session
Pass the variable as a cookie
Pass the variable as part of the URL
8. How can we know the total number of elements of Array?
sizeof($array_var)
count($array_var)
9. How can we create a database using php?
mysql_create_db();
10. What is the functionality of the function strstr and stristr?
strstr() returns part of a given string from the first occurrence of a given substring to the end of the string.
For example:strstr("user@example.com","@") will return "@example.com".
stristr() is idential to strstr() except that it is case insensitive.
11. What are encryption functions in PHP?
CRYPT(), MD5()
12. How to store the uploaded file to the final location?
move_uploaded_file( string filename, string destination)
13. Explain mysql_error().
The mysql_error() message will tell us what was wrong with our query, similar to the message we would receive at the MySQL console.
14. What is Constructors and Destructors?
CONSTRUCTOR : PHP allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.
DESTRUCTORS : PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence.
15. Explain the visibility of the property or method.
The visibility of a property or method must be defined by prefixing the declaration with the keywords public, protected or private.
Class members declared public can be accessed everywhere.
Members declared protected can be accessed only within the class itself and by inherited and parent classes.
Members declared as private may only be accessed by the class that defines the member.
16. What are the differences between Get and post methods.
There are some defference between GET and POST method
1. GET Method have some limit like only 2Kb data able to send for request
But in POST method unlimited data can we send
2. when we use GET method requested data show in url but
Not in POST method so POST method is good for send sensetive request
17. What are the differences between require and include?
Both include and require used to include a file but when included file not found
Include send Warning where as Require send Fatal Error
18. What is use of header() function in php ?
The header() function sends a raw HTTP header to a client.We can use herder()
function for redirection of pages. It is important to notice that header() must
be called before any actual output is seen.
19. List out the predefined classes in PHP?
Directory
stdClass
__PHP_Incomplete_Class
exception
php_user_filter
20. What type of inheritance that PHP supports?
In PHP an extended class is always dependent on a single base class,that is, multiple inheritance is not supported. Classes are extended using the keyword 'extends'.
21. How can we encrypt the username and password using php?
You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD("Password");
We can encode data using base64_encode($string) and can decode using base64_decode($string);
22. What is the difference between explode and split?
Split function splits string into array by regular expression. Explode splits a string into array by string.
For Example:explode(" and", "India and Pakistan and Srilanka");
split(" :", "India : Pakistan : Srilanka");
Both of these functions will return an array that contains India, Pakistan, and Srilanka.
23. How do you define a constant?
Constants in PHP are defined using define() directive, like define("MYCONSTANT", 100);
24. How do you pass a variable by value in PHP?
Just like in C++, put an ampersand in front of it, like $a = &$b;
25. What does a special set of tags <?= and ?> do in PHP?
The output is displayed directly to the browser.
26. How do you call a constructor for a parent class?
parent::constructor($value)
27. What’s the special meaning of __sleep and __wakeup?
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
28. What is the difference between PHP and JavaScript?
javascript is a client side scripting language, so javascript can make popups and other things happens on someone’s PC. While PHP is server side scripting language so it does every stuff with the server.
29. What is the difference between the functions unlink and unset?
unlink() deletes the given file from the file system.
unset() makes a variable undefined.
30. How many ways can we get the value of current session id?
session_id() returns the session id for the current session.
31. What are default session time and path?
default session time in PHP is 1440 seconds or 24 minutes
Default session save path id temporary folder /tmp
32. for image work which library?
we will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with.
33. How can we get second of the current time using date function?
<?php
$second = date(“s”);
?>
34. What are the Formatting and Printing Strings available in PHP?
printf()- Displays a formatted string
sprintf()-Saves a formatted string in a variable
fprintf() -Prints a formatted string to a file
number_format()-Formats numbers as strings
35. How can we find the number of rows in a result set using PHP?
$result = mysql_query($sql, $db_link);
$num_rows = mysql_num_rows($result);
echo "$num_rows rows found";
Rasmus Lerdorf is known as the father of PHP.
2. What is the difference between $name and $$name?
$name is variable where as $$name is reference variable like $name=sonia and $$name=singh so $sonia value is singh.
3. What are the method available in form submitting?
GET and POST
4.How can we get the browser properties using PHP?
<?php
echo $_SERVER[‘HTTP_USER_AGENT’].”\n\n”;
$browser=get_browser(null,true);
print_r($browser);
?>
5. What Is a Session?
A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests. Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.
6. How can we register the variables into a session?
<?php
session_register($ur_session_var);
?>
7. How many ways we can pass the variable through the navigation between the pages?
Register the variable into the session
Pass the variable as a cookie
Pass the variable as part of the URL
8. How can we know the total number of elements of Array?
sizeof($array_var)
count($array_var)
9. How can we create a database using php?
mysql_create_db();
10. What is the functionality of the function strstr and stristr?
strstr() returns part of a given string from the first occurrence of a given substring to the end of the string.
For example:strstr("user@example.com","@") will return "@example.com".
stristr() is idential to strstr() except that it is case insensitive.
11. What are encryption functions in PHP?
CRYPT(), MD5()
12. How to store the uploaded file to the final location?
move_uploaded_file( string filename, string destination)
13. Explain mysql_error().
The mysql_error() message will tell us what was wrong with our query, similar to the message we would receive at the MySQL console.
14. What is Constructors and Destructors?
CONSTRUCTOR : PHP allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.
DESTRUCTORS : PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence.
15. Explain the visibility of the property or method.
The visibility of a property or method must be defined by prefixing the declaration with the keywords public, protected or private.
Class members declared public can be accessed everywhere.
Members declared protected can be accessed only within the class itself and by inherited and parent classes.
Members declared as private may only be accessed by the class that defines the member.
16. What are the differences between Get and post methods.
There are some defference between GET and POST method
1. GET Method have some limit like only 2Kb data able to send for request
But in POST method unlimited data can we send
2. when we use GET method requested data show in url but
Not in POST method so POST method is good for send sensetive request
17. What are the differences between require and include?
Both include and require used to include a file but when included file not found
Include send Warning where as Require send Fatal Error
18. What is use of header() function in php ?
The header() function sends a raw HTTP header to a client.We can use herder()
function for redirection of pages. It is important to notice that header() must
be called before any actual output is seen.
19. List out the predefined classes in PHP?
Directory
stdClass
__PHP_Incomplete_Class
exception
php_user_filter
20. What type of inheritance that PHP supports?
In PHP an extended class is always dependent on a single base class,that is, multiple inheritance is not supported. Classes are extended using the keyword 'extends'.
21. How can we encrypt the username and password using php?
You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD("Password");
We can encode data using base64_encode($string) and can decode using base64_decode($string);
22. What is the difference between explode and split?
Split function splits string into array by regular expression. Explode splits a string into array by string.
For Example:explode(" and", "India and Pakistan and Srilanka");
split(" :", "India : Pakistan : Srilanka");
Both of these functions will return an array that contains India, Pakistan, and Srilanka.
23. How do you define a constant?
Constants in PHP are defined using define() directive, like define("MYCONSTANT", 100);
24. How do you pass a variable by value in PHP?
Just like in C++, put an ampersand in front of it, like $a = &$b;
25. What does a special set of tags <?= and ?> do in PHP?
The output is displayed directly to the browser.
26. How do you call a constructor for a parent class?
parent::constructor($value)
27. What’s the special meaning of __sleep and __wakeup?
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
28. What is the difference between PHP and JavaScript?
javascript is a client side scripting language, so javascript can make popups and other things happens on someone’s PC. While PHP is server side scripting language so it does every stuff with the server.
29. What is the difference between the functions unlink and unset?
unlink() deletes the given file from the file system.
unset() makes a variable undefined.
30. How many ways can we get the value of current session id?
session_id() returns the session id for the current session.
31. What are default session time and path?
default session time in PHP is 1440 seconds or 24 minutes
Default session save path id temporary folder /tmp
32. for image work which library?
we will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with.
33. How can we get second of the current time using date function?
<?php
$second = date(“s”);
?>
34. What are the Formatting and Printing Strings available in PHP?
printf()- Displays a formatted string
sprintf()-Saves a formatted string in a variable
fprintf() -Prints a formatted string to a file
number_format()-Formats numbers as strings
35. How can we find the number of rows in a result set using PHP?
$result = mysql_query($sql, $db_link);
$num_rows = mysql_num_rows($result);
echo "$num_rows rows found";
Subscribe to:
Posts (Atom)
How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide
How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide If you're looking to host a Laravel project on Hostinger’s hPa...
-
What is hooks in codeigniter and how it works CodeIgniter’s Hooks feature provides a means to tap into and modify the inner workings of ...
-
it's my first tutorial on website hacking using SQL Injection attack with easy and simple steps. I have seen many guys they can...
-
Edit an incorrect commit message in Git Amending the commit message git commit -- amend Will open your editor, allowing you to chang...

