Forum Moderators: phranque

Message Too Old, No Replies

rewrite. dynamic and back again

         

LFReD

8:45 am on Apr 17, 2007 (gmt 0)

10+ Year Member



Hi..

Im using this rule..

RewriteRule ^([A-Za-z0-9-]+)/?$ main.php?k=$1

to change this..

[mydomain.com...]

into this..

[mydomain...]

Works great.. but how can I get the benefits of the dynamic url, but keep the clean [mydomain.com...]
?

jd01

12:01 pm on Apr 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi LFRed,

Welcome to WebmasterWorld!

I'm not sure I understand the question…

Works great.. but how can I get the benefits of the dynamic url, but keep the clean http://example.com/xyz

Can you give an example of "works great"?
What doesn't work great, and what you mean by benefits you are thinking you are missing?

If the rule is working correctly, when a visitor clicks on a link to http://example.com/xyz they should be served the information from http://example.com/main.php?k=xyz, but that's about all the rule is designed to accomplish.

Justin

jdMorgan

12:45 pm on Apr 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The key is to use the link "http://example.com/xyz" on all of your pages.

Using the link on your pages makes "http://example.com/xyz" the "real" URL, and "http://example.com/main.php?k=xyz" is just the filepath that the content will be served from.

See this thread [webmasterworld.com] from the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

LFReD

5:29 pm on Apr 17, 2007 (gmt 0)

10+ Year Member



Ok.. I see what's happening.. I was a bit deceptive with my first post. I actually have two main pages main.php and main2.php

I built main.php to add a 'please wait' while i load the main2.php main2.php is a bit heavy on the javascript, (using lots of ajax, dynamically loading widgets etc. but once it's up, requires little or no page refreshing).

so i redirect main.php to main2.php .. passing the 'k' argument along with it. Its at this point the url gets 'real'

There's probably a better way of doing this?

jdMorgan

6:57 pm on Apr 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your post is not clear. Please state what you want to do in terms of URLs and filepaths. It might be helpful to drop the 'deceptiveness' so as not to take us down unproductive, time-wasting paths...

Jim

LFReD

7:40 pm on Apr 17, 2007 (gmt 0)

10+ Year Member



Deceptive was not quite correct. It's a balance between lengthy posts, and trying to be concise.

Your earlier answer was perfect, thanks.

In my last post, I was considering if there's a better way to generate a 'please wait' message while a larger page is loading.. at the moment, rewrites go to main.php, and that page redirects to main2.php... while main2.php is loading, the spinner on main.php spins... looks like a cheap flash loader.. just wondering if this is the best method for this.

jdMorgan

8:02 pm on Apr 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I wouldn't put much faith in that method viz-a-viz search engine ranking -- A page refresh is NOT a redirect, and that front page may eat up much of the real page's ranking power.

Prefaced by saying I'm a server-side purist, and I don't use client-side scripting (JavaScript) for anything except convenience and strictly-optional 'add-on' features, I'd say that the best approach would be to lighten up your 'real' page by moving as much functionality to the server side as possible. Not intending to be condescending in any way, I have observed over the years that people often use the one tool they know to excess, regardless of other possibly-more-efficient options -- "To a man with only a hammer, everything looks like a nail."

I do the same thing myself, here. Sometimes I'll post at length about a complicated mod_rewrite solution, and someone will come along with a much shorter and better alternative solution. Everyone learns here, especially me. :)

Anyway, you've got only a very few seconds, "Please Wait" message or not, to get the visitors to what they want before they click 'Back' and go on to the next search result. Sites that implement features "because we can" rather than "because the user needs them" suffer not in click-through rates, but in stickiness and conversions.

Of course, you may have a specialty site to which none of the above applies -- Millions of sites, and no two the same... :)

Jim

jd01

8:21 pm on Apr 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In my last post, I was considering if there's a better way to generate a 'please wait' message while a larger page is loading.. at the moment, rewrites go to main.php, and that page redirects to main2.php... while main2.php is loading, the spinner on main.php spins... looks like a cheap flash loader.. just wondering if this is the best method for this.

I would look at 'page load order'.

I don't know your specifics, but sometimes you can creatively load images, etc so visitors with slower connections can begin using the site, while it's loading.

EG I load my graphic navigation on "clear background gifs" in the html, then load the actual background image from the style sheet. The end result is the nav gifs are about 5k and load first so visitors can use the navigation, then the background of the navigation is loaded and it looks better, but the nav is usable much before.

Justin

LFReD

7:25 am on Apr 18, 2007 (gmt 0)

10+ Year Member



This site is a bit different.. the primary page is very small, but sends a message, via Ajax to a script that fetches all (er, most) of the elements, styles, scripts etc from a DB, and sends them back (as pure JS) in the response... this JS is then evaluated.. effects, content, styles.. no two pages are the same. What slows it down is the single ajax request to create the page.. the script takes some time to pull it all together, and sends it back... all at once. A second or two and boom.. elements (widgets) flying into place. It's all done on the server, and the JS is just layout/effects tool.

(There is a method to the madness ;)

One thought was to break the ajax request into smaller chunks, send an element, then another request for the next element until they all arrive.