Forum Moderators: phranque

Message Too Old, No Replies

Mod rewrite for dynamic to static conversion

         

ichthyous

5:17 pm on Aug 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi there,

I am a complete newbie to writing Apapche code and was wondering how difficult it would be to convert my dynamic pages to static ones. My dynamic URLs look like this:

http://www.mysite.com/Qstore/Qstore.cgi?CMD=009&DEPT=1021236984&CAT=1060144925&
SUBCAT=1060145054&BACK=A0008A1B01021236984B1C01060144925C1

This URL is about as long as it gets. All of my dynamic pages have similar (or shorter) URLs depending on whether they are department, category, subcategory or product pages. I know that I basically need everything after the? converted into something the SEs can digest and I need a mod rewrite script that replaces the "?" and the "&" with "/". Is that correct? Since I have a mix of both dynamic and static pages on my site would I add the apache mod rewrite code to my .htaccess or my httpd.conf file? Would anyone happen to have an example of a mod rewrite code that would work in this instance? Any advice is appreciated

[edited by: jdMorgan at 10:48 pm (utc) on Aug. 29, 2004]
[edit reason] Fixed side-scroll [/edit]

jdMorgan

10:47 pm on Aug 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, here's how it works:

Modify your script to output SE-friendly URLs, as short and concise as possible.

When these new URLs are requested by clients, use mod_rewrite to convert them back into the format needed to call your script internal to your server.

In some cases, you'll want to mod_rewrite the URLs back to the full long query-string version. In other cases, simply calling the script is enough; you can let the script extract the query parameters from the URL-path in the REQUEST_URI or REQUEST_FILENAME server variables.

Which method you choose depends on how much you want to modify the script.

mod_rewrite is invoked after a request is received by your server, but before any content is served or any scripts are invoked. Therefore, it can modify requested (received or input) URLs, but it cannot modify "output" URLs within the content of served pages.

Start with the references cited in our forum charter [webmasterworld.com], and also try a WebmasterWorld site search [google.com] for "static dynamic URL rewriterule" (no quotes). That will turn up tons of threads on the subject. Just remember that what you need to do is output static-looking URLs from the script, and then rewrite those static URLs when requested to the dynamic URLs needed by your application. Our charter will also explain why I didn't post any code here.

Jim

Marcia

11:45 pm on Aug 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>complete newbie to writing Apapche code

ichtyous, a lot of people are in the same boat, and make no mistake - it is programming, and there's a learning curve that non-programmers can find to be very steep.

The official Apache documentation is quite on the heady side for a newbie non-programmer without technical background; also, a lot of what you see written when looking around takes root level server access, which most who use paid hosting don't have. So it can take figuring out what can be done without, with just .htaccess alone.

There is more to be found, some specifically for implementation when using PHP for example, but these two are simpler for a non-tech newbie to comprehend than the Apache docs. Ralf Engelschall's qualifications go without saying:

Apache URL Rewriting Guide [engelschall.com]

And here's a tutorial here at WebmasterWorld written by DaveAtIFG that's about as simple as it can get

Introduction to Redirecting URLs on an Apache Server
[webmasterworld.com]