View Full Version : .htaccess form mod_rewrite
khering
09-15-2008, 04:27 PM
I am trying to setup my first site. I want to use mod_rewrite to change the URL's on my site to make them more friendly for users and search engine robots. I got a sample script using Mod_Rewrite wizard and put it in .htaccess, but nothing seems to happen. Is there some configuration change that I need to make to enable mod_rewrite?
Here is the script:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?DepartmentID=$1&ProductID=$2 [L]
It is supposed to change "www.giftsfromatree.com/index.php?DepartmentID=10&ProductID=88" to "http://www.giftsfromatree.com/10/88.html".
Falcon1986
09-15-2008, 05:27 PM
Try the following instead and see if it works:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([0-9]+)/([0-9A-Za-z]+)\.html$ /index.php?DepartmentID=$1&ProductID=$2
khering
09-16-2008, 04:52 PM
I thought I replied earlier today, but I don't see it. Anyway, I tried your code, but my links did not change. I am assuming that when one of my links is selected, that the translated url should show in the address line - correct?
Falcon1986
09-16-2008, 06:36 PM
Do you have anything else in your .htaccess file?
Are you using a particular commerce software to run your site? If so, have you checked the software's documentation to see the proper mod_rewrite statements used to modify the appearance of your links?
khering
09-17-2008, 07:52 AM
nothing in .htaccess but your code now. The site is coded from scratch - guided by a book I bought. Nothing about mod_rewrite statements. I am trying to do this based on research I have done on SEO.
shadmego
09-17-2008, 10:09 AM
When I was playing with mod_rewrite, I found that after I put the code in the .htaccess file, I had to go back into my html code and change my links to reflect the url I wanted to use:
old href value
<a href="index.php?DepartmentID=10&ProductID=88">
new href value
<a href="10/88.html">
Now that might not be exactly correct for your situation, but it was similar to what I had to do with some code I was trying to create. It wound up not working for me, but then, I know next to nothing about .htaccess and even less about mod_rewrite ...
~regards
khering
09-27-2008, 11:07 AM
thanks for all the help - now I understand how to use mod_rewrite - it works just fine. Thanks again.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.