JavaScript Editor Ajax software     Free javascripts 



Main Page

Testing mod_rewrite
1.
Create a file named
product.php
in your
seophp
folder, and add this code to it:
<?php
// display product details
echo ‘You have selected product #‘ . $_GET[‘product_id’];
?>
2.
Test your simple PHP script by loading
http://seophp.example.com/product.php?product_
id=3
. The result should resemble Figure 3-4.
3.
Create a file named
.htaccess
in your
seophp
folder, and add the following lines to it. Their
functionality is explained in the section that follows.
RewriteEngine On
# Translate my-super.product.html to /product.php?product_id=123
RewriteRule ^my-super-product\.html$ /product.php?product_id=123
Here’s a little detail that’s worth a mention. The
.htaccess
file is technically a file with an empty
name, and the
htaccess
extension. Depending on the settings of your Windows system, this file
may not be easily visible in Windows Explorer.
4.
Switch back to your browser again, and this time load
http://seophp.example.com/
my-super-product.html
. If everything works as it should, you should get the output
that’s shown in Figure 3-5.
If you get a server error at this point, most probably the mod_rewrite module isn’t correctly enabled.
Make sure you’ve restarted the Apache server after enabling mod_rewrite in
httpd.conf
. Open the
error.log
file from the Apache logs directory to read details about the error.
Figure 3-5
51
Chapter 3: Provocative SE-Friendly URLs
c03.qxd:c03 10:39 51


JavaScript Editor Ajax software     Free javascripts 
Bitcoin Dice - Crypto Casino