Jump to content
Larry Ullman's Book Forums

Mod_Rewrite Is Not Working With My Urls


Recommended Posts

I am trying to make SEO friendly URLs of using apache mod_rewrite.

My normal URLs is something like this -

index.php?p=about
index.php?p=contact
index.php?p=this

My expecting SEO friendly URLs should be something similar to this -

localhost/php_advance/ch02/about
localhost/php_advance/ch02/contact
localhost/php_advance/ch02/this

I tried it with creating a .htaccess file and doing some changes to my apache httpd.conf file.

This is my .htaccess file

<ifModule mod_rewrite.c>

# Turn on the engine:
RewriteEngine on

# Set the base to this directory:
RewriteBase /php_advance/ch02/

# Redirect certain paths to index.php:
RewriteRule ^(about|contact|this|that|search)/?$ index.php?p=$1

</ifModule>

And also, At the end of the httpd.conf file, I added some code like this -

<Directory "C:/wamp/www/php_advance/ch02">
AllowOverride All
</Directory>

NOTE: I am using WAMP server and Windows 07

But this coding is not working for me. Hope someone will help me out. Thank you.

Link to comment
Share on other sites

Could you please provide some more info into how it's not working? Do you see any errors? What's not working? Where's the index.php file?

As I've mentioned many times before with mod_rewrite scripts, start with something very simple that's easy to confirm the operation of, and then slowly make things more difficult until you get what you want.

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...