Prev | Current Page 286 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

If you??™re working with
a web hosting account, most likely mod_rewrite is already enabled. If you??™ve installed Apache yourself, you
may need to enable mod_rewrite manually. Fortunately, this is a simple task. Open the Apache configuration
file, httpd.conf, and make sure the following line isn??™t commented by being prefixed by a hash sign (#). If
it is, remove the hash, save the file, and restart Apache.
LoadModule rewrite_module modules/mod_rewrite.so
?– Tip The Apache configuration file is located, by default, in C:\xampp\apache\conf\ on a Windows
XAMPP installation. On a typical Linux installation, you??™ll find it in /opt/lampp/etc/. Don??™t forget to restart
Apache after making any changes to httpd.conf! If you get any errors, check the Apache error logs to find
more details about the error.
2. Create a file named .htaccess in your project??™s root folder (C:\tshirtshop), and type the following code
in (we will discuss it in detail later):

# Enable mod_rewrite
RewriteEngine On
CHAPTER 7 ?–  SEARCH ENGINE OPTIMIZATION 192
# Specify the folder in which the application resides.
# Use / if the application is in the root.
RewriteBase /tshirtshop
# Rewrite to correct domain to avoid canonicalization problems
# RewriteCond %{HTTP_HOST} !^www\.example\.com
# RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# Rewrite URLs ending in /index.


Pages:
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298