Forum Moderators: phranque
I'm working on a site right now in which we have a query string for the product catalog which looks like this:
domain.com/product.php?productid=12345&cat=1&page=1
domain.com/PRODUCT_NAME/product.php?productid=12345&cat=1&page=1
Now, I'm 90% sure that I have to create a RewriteMap that links to a perl script in which i create a database connection, produce a query, and then stick it in the url.
Problem number 1 is that I'm a recent graduate, and they don't teach Perl at the school that I attended anymore.
Problem number 2 is I can't seem to find any examples of anyone who's done this, and believe me, I have tried.
In a perfect world, the numeric product identfier would disappear completely, and i could completely clean the url, but I'm hoping to do one thing at a time, and that that will be the natural extension of the result of this.
Any help that I can get would be greatly appreciated.
I managed to get things started using the following .htaccess:
RewriteEngine on
RewriteBase /forum/
RewriteRule ^forum-(.*).html viewforum\.php\?f=$1 [L]
RewriteRule ^topic-(.*).html viewtopic\.php\?t=$1 [L]
As you can see, I am currently doing the testing of mod_rewrite in an inactive forum. I don't want to deploy it to the production server until I know things are going to work.
I've showed to my partner, and he has asked me two things:
1) Is there a way we can make the path show up differently without changing the php code itself? What this means is that he wants the current linked references to remain the same, and have the new address show up in the address bar when it is forwarded.
2) Can we do the database call so we don't have to change the query string.
If anyone has some advice they could provide, I'd really appreciate it.
No, not unless you "wrap" the script inside another script that can modify its output. Mod_rewrite is invoked after an http request is received, but before any content is served. Thus, it can only change an incoming requested URL, and not the output of any page or script.
This is, unfortunately, one of those things that is much easier if taken into account from the start. Even major big-money commercial scripts miss this "search-friendly-URL" issue, leaving many sites at a distinct disadvantage with regard to search. :(
Jim