Forum Moderators: phranque
As I understand it from reading other forums, many people have had trouble with getting the rewrite script to work on Godaddy's shared hosting (Linux with Frontpage extensions). Can someone please tell me whether the below script will work on my htaccess file with the given constraints mentioned above?
Options +FollowSymLinks
> > RewriteEngine on
> > RewriteRule proddetail/prod/(.*)/ proddetail.php?prod=$1
> > RewriteRule proddetail/prod/(.*) proddetail.php?prod=$1
Also, what 301 redirect should be used to make my old dynamic pages redirect to the new urls.
Thanks,
Chris
[mysite.com...]
I am trying to rewrite them to look like this:
[mysite.com...]
For my products & categories:
[mysite.com...]
Rewritten to [mysite.com...]
[mysite.com...]
Rewritten to [mysite.com...]
RewriteRule ^proddetail/prod/([^]+)/?$ /proddetail.php?prod=$1 [L]
The thread Changing Dynamic URLs to Static URLs [webmasterworld.com] from our Apache forum library [webmasterworld.com] may be of use to you.
Jim
However, if you wish to change the links on your pages to a 'friendly' format, then you must modify your script to produce those friendly links on your pages. That is the only way to change a URL in a link on your page.
mod_rewrite is not a "page output modifier," it is a requested-URL-to-filename translator, and works as the client (e.g browser or robot) request is received by your server.
For these reasons, your friendly URL design must contain sufficient information to re-create the calling parameters needed by your script.
---
You can make your friendly URL *longer* so that it contains not only the title of the page or name of the product, but also the product number. mod_rewrite can then strip off the title/name, and pass only the product number to products.php, if that sounds like something you'd want to do. But be careful not to make the friendly URL too long, or it will look spammy and may trigger site-quality flags.
---
Coming up with a rigorous, scalable, and maintainable "plan" for your friendly URLs is the hard part; If that's properly done, coding the rewrite rule (or rules) is easy.
Jim
Change your category and product scripts to output .htm URLs as the links on your pages.
And *at the same time* add a RewriteRule in .htaccess to 'map' those .htm URLs back to the prod and cat scripts when the .htm links are clicked and requested from your server.
These two parts of the solution should be deployed concurrently.
Really, I can't explain it much better than I did in the cited thread. Perhaps another respondent may be more attuned to your question if I'm missing it.
Jim