Originally Posted by war59312
Yea that would be great too.
Thanks a ton,
Will
PS: Bet this helps with google too.
Hey Will,
It should help with all search engines. Google started indexing variables within the URL, but to play it on the safe side, it wouldn't hurt to use this method.
Please take note of the edit above. I had to correct the URL you would use if you were to apply the code in my last post.
Here is the code to place within you .htaccess if you want the folder structure. Remember though - since the URL is being re-written, your images may break because of the folder structure. I will comment on that later. Here is the code you would place in the .htaccess if you were to want folder structure URL manipulation:
RewriteEngine On
RewriteRule ^catalog/([^/]+)/([^/]+)(.*)$ /catalog$3?$1=$2 [QSA,N]
RewriteRule ^catalog/?$ /catalog.php [QSA,L]
The URL to use for this would be (using above example URL):
Now, the way to fix the image breakage, there are 2 ways:
- Have all your images with full paths (ex- http://www.mydomain.com/images/image.jpg)
- Add more lines to the .htaccess
Let's say you had an image directory (src="images/image.jpg") and a scripts directory (src="scripts/script.js") that needed to be adjusted with how many folders you are using in the URL - you would then use this:
RewriteRule ^.+(images|scripts)/(.*)$ /$1/$2 [L]
This would bring you back to the doc root for your images and scripts directory. This way it will stay consistant with no images or scripts breaking do to the changing of the URL structure.
If you do not modify this, you will end up with this as an example:
Where it should be:
Also, if you have more than 9 variable pairs (&something=something) within your URL and are running apache >1.3.28 or >2.0.45, you may want to add this line within your .htaccess:
RewriteOptions MaxRedirects=25
This is to increase the maximum number of redirects from the default value 10 to 25 (these are so called internal redirects). This is an apache prevention for endless loops.
All this I learned from Robert over at
http://forum.modrewrite.com/. This guy was totally helpful and has gotten back to me with every question I threw at him.
I hope this helps you out Will as much as it did for me!
Enjoy!
-SlickVic78