Using this technique you will see product.html in the address bar of the browser but the actual file name remains product.php and you don’t need to rename the file extension. Furthermore you can rewrite the URL like product.php?id=5 to product-5.html.
what is the benefits of rewriting URL?
When a search engine visits the dynamic url like product.php?id=5 it does not give much importance to that URL as search engine sees “?” sign treat it as a url which keeps on changing. so we’re converting the dynamic URL like the product.php?id=5 to static url format like product-5.html. We’ll rewrite the url in such a way that in browser’s address bar it will display as a product-5.html but it actually calls the file product.php?id=5. So that why these kind of URL also named as SEO friendly URL.
what is required for URL rewriting ??
To rewrite the URL you must have the mod_rewrite module must be loaded in apache server. And furthermore, FollowSymLinks options also need to be enabled otherwise you may encounter 500 Internal Sever Error. If you don’t know much about mod_rewrite module then please check this post to know how to check and enable mod_rewrite module in apache?
Examples of url rewriting for seo friendly URL
For rewriting the URL, you should create a .htaccess file in the root folder of your web directory. And have to put the following codes as your requirement.
1)Rewriting product.php?id=12 to product-12.html
It is a simple redirection in which .php extension is hidden from the browser’s address bar and dynamic url (containing “?” character) is converted into a static URL.
RewriteEngine on
RewriteRule ^product-([0-9]+)\.html$ product.php?id=$1
2) Rewriting product.php?id=12 to product/ipod-nano/12.html
SEO expert always suggest to display the main keyword in the URL. In the following URL rewriting technique you can display the name of the product in URL.
RewriteEngine on
RewriteRule ^product/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ product.php?id=$2
3) Redirecting non www URL to www URL
If you type yahoo.com in browser it will be redirected to www.yahoo.com. If you want to do same with your website then put the following code to .htaccess file. What is benefit of this kind of redirection?? Please check the post about SEO friendly redirect (301) redirect in php and .htaccess.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^optimaxwebsolutions\.com$
RewriteRule (.*) http://www.optimaxwebsolutions.com/$1 [R=301,L]
4) Rewriting yoursite.com/user.php?username=xyz to yoursite.com/xyz
Have you checked zorpia.com.If you type http://zorpia.com/roshanbh233 in browser you can see my profile over there. If you want to do the same kind of redirection i.e http://yoursite.com/xyz to http://yoursite.com/user.php?username=xyz then you can add the following code to the .htaccess file.
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1
5) Redirecting the domain to a new subfolder of inside public_html.
Suppose the you’ve redeveloped your site and all the new development reside inside the “new” folder of inside root folder.Then the new development of the website can be accessed like “test.com/new”. Now moving these files to the root folder can be a hectic process so you can create the following code inside the .htaccess file and place it under the root folder of the website. In result, www.test.com point out to the files inside “new” folder.
Helpopedia provides valuable information on a variety of topics such as computer hardware, graphics, web development, networking and the like. You can also post your problems and get them solved at the touch of a button. Also, if you are interested in sharing and writing, please contact us on the following e-mail address: dihaz09@gmail.com We look forward to your active participation and suggestions. Helpopedia™
Showing posts with label Scripts. Show all posts
Showing posts with label Scripts. Show all posts
Wednesday, September 23, 2009
Sunday, July 19, 2009
Program a Fake Computer Virus in 60 Seconds =)
Today we will create a Program which is a fake virus that will reboot your system even bypassing Anti virus.
1. Open your notepad and write down the following code, shutdown -r -t 5 -c "Your computer is diseased.LaLalaLALALaLlala.Byeeee!! Byee!!!"
2. Save the program. Select file on your notepad and click "save as." On the dialogue box think of a file name that would catch a person's curiosity and compel that person to click on our little program. In this example we'll use "secrets", and then you need to append the name with ".bat", so you'll saving the program like this, secrets.bat. Click the save button.
3. Test the fake computer virus. Click the shortcut or icon of the program you just saved to run the program. You'll get the custom error message you created and a countdown timer. At the end of the countdown your computer will automatically reboot.
4. To stop the program select Start then click Run. You can stop the program from rebooting your computer by selecting Start then select Run. In the dialogue box type in "shutdown -a", this will prevent the program from continuing.
This fake computer virus is a harmless prank you can pull on your friends. Copy and transfer the file to their computer, hide it somewhere other than the desktop. Once it is hidden, right-click the file and choose "Send To" then select "Desktop (create shortcut). Go to the shortcut you created on the desktop then right-click it and select properties. On the Shortcut tab click the "Change Icon" button and choose an icon like the internet explorer icon. This will make it look like an innocent icon =))
Or you can attach this program with startup of users computer. User will never b able to start his/her computer or you can attach it in autorun.inf file of any drive or Flash Drive wheneva user will click on drive his/her PC will restart =)) i m saving this for next tutorial =D
P.S. batch files can be very dangerous Programs. They Can shutdown, Restrat, or even Format Your Hard Drive with out and prompt message. I m not sharing format commands as they can be dangerous. Just Enjoy with these fun commands.
1. Open your notepad and write down the following code, shutdown -r -t 5 -c "Your computer is diseased.LaLalaLALALaLlala.Byeeee!! Byee!!!"
- The " -r" tells your computer system to restart or reboot.
- the " -t" command determines how much countdown time before system reboot, the number that follows the command in " -t 5" is the specified time in seconds you allot before the system automatically reboots. The number could be anything you want to specify like 10 seconds, in this example we put in a 5 second countdown.
- The " -c" command in the program, lets you create your custom error message, think of something that would alarm the owner of the computer.
2. Save the program. Select file on your notepad and click "save as." On the dialogue box think of a file name that would catch a person's curiosity and compel that person to click on our little program. In this example we'll use "secrets", and then you need to append the name with ".bat", so you'll saving the program like this, secrets.bat. Click the save button.
3. Test the fake computer virus. Click the shortcut or icon of the program you just saved to run the program. You'll get the custom error message you created and a countdown timer. At the end of the countdown your computer will automatically reboot.
4. To stop the program select Start then click Run. You can stop the program from rebooting your computer by selecting Start then select Run. In the dialogue box type in "shutdown -a", this will prevent the program from continuing.
This fake computer virus is a harmless prank you can pull on your friends. Copy and transfer the file to their computer, hide it somewhere other than the desktop. Once it is hidden, right-click the file and choose "Send To" then select "Desktop (create shortcut). Go to the shortcut you created on the desktop then right-click it and select properties. On the Shortcut tab click the "Change Icon" button and choose an icon like the internet explorer icon. This will make it look like an innocent icon =))
Or you can attach this program with startup of users computer. User will never b able to start his/her computer or you can attach it in autorun.inf file of any drive or Flash Drive wheneva user will click on drive his/her PC will restart =)) i m saving this for next tutorial =D
P.S. batch files can be very dangerous Programs. They Can shutdown, Restrat, or even Format Your Hard Drive with out and prompt message. I m not sharing format commands as they can be dangerous. Just Enjoy with these fun commands.
Install a Free Message Board PHP Script
Having your own website is a good way to get your message or opinions out and share them with other people. You can market your own products through your website or offer services. For whatever reason you want to have a website, it is always good to have a way for people to communicate their thoughts and opinions with you and to others who may find their way to your website. In the old days offices, institutions, clubs or schools would have a bulletin board or a message board for people to post anything they want to share with other people. But now as we use the computer and the Internet more often, message boards take on a new venue, one where the whole world can join in. People on the Internet can post topics and get a discussion online when people reply to the topics. To put up a message board on your website you can install a free message board PHP script.
1. Download a free message board PHP script. Find websites offering free message boards to download. You will find numerous sites with free download-able message boards, pick the one you prefer and download the files to your desktop. Once it is downloaded to your computer, open the folder containing the files and search for the read me file. It will contain the instructions you need to install the message board to your website. Follow the instructions to set up the settings, like the administrative password, the title and URL of your website in your text editor.
2. Upload the message board through FTP. You’ll to open your FTP program to upload the message board files on to your server. Create a folder and name it board in your server
’s directory. Publish or transfer the message board files to the board folder you created on your server.
3. Create a directory called msg. Once you have all the files on your server, create another folder called “msg” then right click the folder to change the folder’s file attribute giving it a 777 numeric value. Locate the threads.txt and count.txt, give it a 666 numeric value in the file attributes for each.
You can now text the message board on your website. You can customize the message board through the CSS file in the mboard.php file.
Downloading and installing a free message board PHP script on your website is the best way to have a simple and effective message board on your website, and as a bonus it won’t take up too much space on your server.
1. Download a free message board PHP script. Find websites offering free message boards to download. You will find numerous sites with free download-able message boards, pick the one you prefer and download the files to your desktop. Once it is downloaded to your computer, open the folder containing the files and search for the read me file. It will contain the instructions you need to install the message board to your website. Follow the instructions to set up the settings, like the administrative password, the title and URL of your website in your text editor.
2. Upload the message board through FTP. You’ll to open your FTP program to upload the message board files on to your server. Create a folder and name it board in your server
’s directory. Publish or transfer the message board files to the board folder you created on your server.
3. Create a directory called msg. Once you have all the files on your server, create another folder called “msg” then right click the folder to change the folder’s file attribute giving it a 777 numeric value. Locate the threads.txt and count.txt, give it a 666 numeric value in the file attributes for each.
You can now text the message board on your website. You can customize the message board through the CSS file in the mboard.php file.
Downloading and installing a free message board PHP script on your website is the best way to have a simple and effective message board on your website, and as a bonus it won’t take up too much space on your server.
Learn PHP on 15 Minutes
Step 1:
To be able to execute PHP scripts, you need at least a working PHP installation+ web server. Linux, Apache, MySQL and PHP are the best combinations. PHP also can run under Microsoft Windows, too.
PHP installation and configuration can be made easy with tools such as Apache2Triad or XAMPP which automate web server and PHP installation.
PHP script is stored in text format file so you need text editor. Notepad and Notepad++ are enough for your PHP development needs. However, you may opt to invest in more advanced tools such Dreamweaver or Eclipse.
Step 2:
PHP script is anything between pair. You can also use . The first is most widely used.
print '
?>
Output of the following code will be same as the previous code:
print '
Hello this is my first script
To be able to execute PHP scripts, you need at least a working PHP installation+ web server. Linux, Apache, MySQL and PHP are the best combinations. PHP also can run under Microsoft Windows, too.
PHP installation and configuration can be made easy with tools such as Apache2Triad or XAMPP which automate web server and PHP installation.
PHP script is stored in text format file so you need text editor. Notepad and Notepad++ are enough for your PHP development needs. However, you may opt to invest in more advanced tools such Dreamweaver or Eclipse.
Step 2:
PHP script is anything between pair. You can also use . The first is most widely used.
print '
Hello this is my first script
';?>
Output of the following code will be same as the previous code:
print '
Hello this is my first script
';
?>
Step 3:
The power of PHP lies on the capability to change how HTML code will output. The following code will output different HTML codes when you change the name.
$aname=$_GET['name'];
print 'Hello '.$name.' this is my first script
'; ?>
Save this script as welcome.php in the document root directory (for Apache web server, this is usually htdocs directory). Open your web browser and type http://localhost/welcome.php?name=Zamrony
Step 4:
$_GET is a predefined variable which stores lists of parameters passed to the script. It is an array. If you change http://localhost/welcome.php?name=zamrony&country=Indonesia, $_GET will contain more items.
$aname=$_GET['name'];
$acountry=$_GET['country'];
print 'Hello '.$name.' from '.$acountry.' .
this is my first PHP script
';
?>
It will print Hello Zamrony from Indonesia. This is my first PHP script.
Step 5:
$aname, $acountry and $_GET are all variables in PHP. Any variables in PHP should be prefixed with dollar sign. Variable names must only contain alphanumeric and underscore characters where the first character in variable names should be alphabet characters or underscores.
This is invalid variable name:
$123
$1aname
$*jskk
This is valid variable name:
$k123
$j
$_
$_test
$k123k
$KK
PHP is case sensitive. Variable $kk is not $KK.
this is my first PHP script
How to Create a Basic Login Script in PHP
Interested in creating your own forum page, blog, or even a shopping cart? A login area is the first step. Here is how to create a script for it in PHP.
Steps:
1. Create the login database and table. For the purposes of the code examples below, we will assume the database name to be "test" and the table name to be "members". The database and table can be created through the control panel of your webhost. The "members" table will store the username and the passwords of all the people would be allowed access via this login script. The table should have a unique id field as the primary key, a username field, and a password field.
2. Create the login interface. This is an html page containing a form, two text boxes for the user name and password, and a submit button. As long as you have these elements, you may design the layout however you wish.
Example:
3. Create the php script that will check the login input against the database. This script will connect to the database, send a query and retrieve the result, check to see if the username and password is correct and send you to the next page depending on the result of the comparison.
Example (connecting to the database):
$host="localhost"; // Host name
$username=""; // username
$password=""; // password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Replace database connect functions depending on database you are using.
mysql_connect("$host", "$username", "$password");
mysql_select_db("$db_name");
Example (submitting query and retrieving results):
// username and password sent from form
//NEVER Remove the mysql_real_escape_string. Else there could be an Sql-Injection!
$myusername=mysql_real_escape_string($_POST['myusername']);
$mypassword=mysql_real_escape_string($_POST['mypassword']);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
Example (checking results):
// Replace counting function based on database you are using.
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
Example (direct user based on result):
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
} else {
echo "Wrong Username or Password";
}
4. Create the page that will display after login success. This script will start your session and display an html message of your choosing.
Example:
// Check if session is not registered , redirect back to main page.
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
Login Successful
5. Create logout script. This step is optional as sessions can time out. If you wish to create one, you will need a button or link to initiate the script and a message to confirm the success of logging out.
Example:
session_start();
session_destroy();
?>
Tips
* Replace the database functions in your script with the appropriate functions for the database you are using (e.g. SQLITE, Microsoft SQL, etc.)
* Depending on your requirements, add security checks to your script.
* Try using CSS and various HTML elements to create an interesting look for your login and message pages.
Steps:
1. Create the login database and table. For the purposes of the code examples below, we will assume the database name to be "test" and the table name to be "members". The database and table can be created through the control panel of your webhost. The "members" table will store the username and the passwords of all the people would be allowed access via this login script. The table should have a unique id field as the primary key, a username field, and a password field.
2. Create the login interface. This is an html page containing a form, two text boxes for the user name and password, and a submit button. As long as you have these elements, you may design the layout however you wish.
Example:
3. Create the php script that will check the login input against the database. This script will connect to the database, send a query and retrieve the result, check to see if the username and password is correct and send you to the next page depending on the result of the comparison.
Example (connecting to the database):
$host="localhost"; // Host name
$username=""; // username
$password=""; // password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Replace database connect functions depending on database you are using.
mysql_connect("$host", "$username", "$password");
mysql_select_db("$db_name");
Example (submitting query and retrieving results):
// username and password sent from form
//NEVER Remove the mysql_real_escape_string. Else there could be an Sql-Injection!
$myusername=mysql_real_escape_string($_POST['myusername']);
$mypassword=mysql_real_escape_string($_POST['mypassword']);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
Example (checking results):
// Replace counting function based on database you are using.
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
Example (direct user based on result):
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
} else {
echo "Wrong Username or Password";
}
4. Create the page that will display after login success. This script will start your session and display an html message of your choosing.
Example:
// Check if session is not registered , redirect back to main page.
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
Login Successful
5. Create logout script. This step is optional as sessions can time out. If you wish to create one, you will need a button or link to initiate the script and a message to confirm the success of logging out.
Example:
session_start();
session_destroy();
?>
Tips
* Replace the database functions in your script with the appropriate functions for the database you are using (e.g. SQLITE, Microsoft SQL, etc.)
* Depending on your requirements, add security checks to your script.
* Try using CSS and various HTML elements to create an interesting look for your login and message pages.
Subscribe to:
Posts (Atom)