Forum Moderators: phranque

Message Too Old, No Replies

Rewrite script for Godaddy-shared hosting- w/ FP extensions

htaccess script using Frontpage extensions on GoDaddy

         

jonescd

7:36 pm on Jan 8, 2007 (gmt 0)

10+ Year Member



Fellow Webmasters,

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

jonescd

7:44 pm on Jan 8, 2007 (gmt 0)

10+ Year Member



Forgot to mention. My current dynamic urls look like this:

[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...]

jdMorgan

9:36 pm on Jan 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can't speak for GD, but you could replace both rules with:

RewriteRule ^proddetail/prod/([^]+)/?$ /proddetail.php?prod=$1 [L]

However, this cannot 'create' the "actual-distance-before-500" information; Whatever information is required in the proddetail URL-path must be present in the requested URL-path.

The thread Changing Dynamic URLs to Static URLs [webmasterworld.com] from our Apache forum library [webmasterworld.com] may be of use to you.

Jim

jonescd

2:43 am on Jan 9, 2007 (gmt 0)

10+ Year Member



jdMorgan,

Will your changes to the script command the .htm extension or do I physically add those on the end of my created urls in my spreadsheet columns?

For example,

category-product-producttype.htm

jdMorgan

3:54 am on Jan 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure of your exact question, but re-read that tutorial carefully: mod_rewrite doesn't "command" anything, it takes a 'static' or 'search-engine friendly' URL in an incoming request, and translates that to a properly-formatted call to your products.php script. It does this by taking information from pre-defined fields of the friendly URL, and using that to construct the name-value pairs required by your script.

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

jonescd

4:14 am on Jan 9, 2007 (gmt 0)

10+ Year Member



I shouldn't have used the term command. How do I have the dynamic url give a .htm address to the user? Is it in the htaccess code as well? If so what would I add to the code I mentioned above?

jdMorgan

4:34 am on Jan 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> How do I have the dynamic url give a .htm address to the user?

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