Forum Moderators: phranque
# Rewrite static URLs to dynamic
RewriteRule (.*)\.htm$ /proddetail.php?prod=$1
#
# Redirect only client-requested dynamic URLs to static
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /proddetail\.php\?prod=([^&]+)\ HTTP/
RewriteRule ^proddetail\.php$ [yourstore.com...] [R=301,L]
I am using GoDaddy Linux with Frontpage extensions
The above rewrite is my htaccess code for getting my proddetail pages to redirect from dynamic to .htm urls.
It works fine. However, I also have pages like this one: [mystore.com...]
If I were to perform a rewrite to .htm for that url would I just simply substitute products for proddetail in the htaccess code mentioned above or is there alot more to it than that to change within my includes files that must take place (I know that the mod that I purchased had three files modified in the inc files for the proddetail rewrite mentioned above)?
Thanks,
Chris
The work-around is to retain the "cat" identifier in the static URLs for categories, and yes, I suspect that will require some work on the script configuration, or perhaps even on the script code itself.
Ideally, the URL structure of a site with multiple "classes" of pages, such as products, categories, forums, etc. should be designed to retain the class identifiers when changed from dynamic URLs to static URLs. Just as an example, something like:
example.com/show.php?product=100239 --> example.com/prod/100239
example.com/show.php?category=43702 --> example.com/cat/43702
In this way, static URL requests can be rewritten to dynamic pages, and direct dynamic URL requests can be redirected back to static URLs at will, and the potential for collisions between identical numbers belonging to different classes can be avoided.
This answer is general because I know nothing of your site or its URL and file layout, and because I know nothing of the script that you are using. Hopefully, it's still clear enough to make sense, and provide you with an abstract way to define your goals and requirements to avoid problems.
Jim
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
# Rewrite static URLs to dynamic
RewriteRule (.*)\.htm$ /products.cat?prod=$1
#
# Redirect only client-requested dynamic URLs to static
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /products\.php\?cat=([^&]+)\ HTTP/
RewriteRule ^products\.php$ [yourstore.com...] [R=301,L]
It is helpful to look at URLs as "data" provided to mod_rewrite, upon which mod_rewrite will make decisions. By removing any hint of the "type" of page (e.g. product, category, etc.) from the requested URL (usually originating as a link on one of your pages), you take away information that mod_rewrite *may* need to properly direct requested static URLs to dynamic script calls.
Hopefully, that's clearer -- As I said, I can't be more specific because I don't know anything about your URL-layout, file layout, or scripts.
Jim
Please note that in order to keep this forum spam-free, we allow neither "programmer-for-hire" nor "help wanted" solicitations on WebmasterWorld.
Jim