Forum Moderators: phranque

Message Too Old, No Replies

coding methods & mod_rewrite

inline url writing with mod_rewrite

         

orxata

9:54 pm on Oct 30, 2003 (gmt 0)

10+ Year Member



Hi out there, my first post here =)

I'm currently reaching all the problems u are discussing a lot in those forums about apache and mod_rewrite and more generally making SE friendly sites...

I've succeeded compiling and setting mod_rewrite with my APACHE, and it rewrites well an URL like:

1/ [mydomain.com...]

into

2/ [mydomain.com...]

my PROBLEM is the following:

how should i CODE my HTML? have i to think writing url like #2? It's a bit hard to maintain!
Or is there a wway to rewrite html inline url dynamicaly?

Thx in advance, and btw great forums

jdMorgan

10:26 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



orxata,

Welcome to WebmasterWorld [webmasterworld.com]!

The purpose of URL rewriting in cases like this is to present "friendly" URLs to search engine spiders. Therefore, your HTML pages and any scripts you use should output "friendly" URLs. Mod_rewrite is then used to convert those friendly URLs, when requested by a browser or spider, back into the form required by your scripts.

The critical thing to undestand is *when* mod_rewrite executes. It runs after an incoming HTTP request is received, and before any file content is served. Once the content is served, mod_rewrite will not run again until the next HTTP request is received.

Therefore mod_rewrite cannot change the "output" of an HTML page or a script, it can only change the name by which that page or script is initially called.

See API Phases in the Internal Processing section of the mod_rewrite documentation [httpd.apache.org].

Jim

orxata

8:50 am on Oct 31, 2003 (gmt 0)

10+ Year Member



k thx for response,

i was afraid of such a solution, it means i will have to have a code that generate SE friendly url in the same way that mod_rewrite works...

If there's any tips about that that can help i'd be glad knowing it =)

Anyway HF webmasters ++

Longhaired Genius

10:34 am on Oct 31, 2003 (gmt 0)

10+ Year Member



Maybe your urls are too friendly; you could rewrite them like this: h**p://mydomain.com/thiscat-thisfile, with a dash instead of a slash. You dont really need the .html either; your server will send the php output file as html.