Forum Moderators: coopster
Ok, to the matter at hand. I decided to try to get better search engine placement. My dynamic URLs are only 1 name/value pair. That one parameter is usually an ID value (which is my primary key) to my MySQL database. The dynamic URL works well to me.
Still everybody is saying to go with static URLs. Ok. I will listen to the general consensus.
I have given up on understanding mod rewrites. So, here is my alternative:
The flat text file will STILL query the database with the primary key, but it will all be behind a static URL with a .PHP extension.
I will be hard coding the new PHP script with a variable assignment where the PHP script will read the variable instead of retrieving it from the URL GET statement.
So, to Google and search engines like it, a static URL will be in the forefront of the spider.
I am not crazy enough to write separate flat text files for each PHP file. So, I wrote a script to create the flat text files after querying the database and those flat text files will query the text files with a convention of
$id=WIDGETS;
instead of URL?id=widgets
Is this the same thing as dynamic URLs or the same result of a Mod Rewrite?
Please give me your viewpoint on this.
I have given up on understanding mod rewrites.
I completely sympathise!
So, here is my alternative:
And here is mine, which I think is simpler, or at least more generic for less work:
Read [httpd.apache.org...] and ensure this "new behavior" is available on your server.
Then write a single ERRORDOCUMENT 404 handler in PHP.
When it gets a URL like:
www.widget.com/prog-name/param1/data1/param2/data2
access the REDIRECT_QUERY_STRING to find /prog-name/..snip../data2
Turn that into the expected query string for prog-name.php.
Execute prog-name.php...It'll never know it wasn't invoked as:
www.widget.com/prog-name.php?param1=data1¶m2=data2
You are effectively doing URL rewriting in PHP -- a language you understand.
And (unlike entries in .htaccess which get accessed every time) your 404 processor is only invoked when an "unknown" URL is processed -- theoretically, that is a lower loading on the server.
(I've not tried this. But it should work. Let me know if it doesn't).
For example:
header("HTTP/1.1 200 OK");
Use that function at the top of your 404 script and you will be fine.
I wouldn't give up on mod_rewrite though. Let me know what you are trying to do and I will be happy to help.
My only comment would be in response to your question, Is this the same thing as dynamic URLs or the same result of a Mod Rewrite?
I would have to answer no. The reason is because of your own statement,
I will be hard coding the new PHP script with a variable assignment where the PHP script will read the variable instead of retrieving it from the URL GET statement.
You see, the terms hard coding and dynamic cancel themselves here, you have one or the other, know what I mean?
What is a non-canonic web address anyway?
Canonical address:
[something.mydomain.com...]
Non-Canonical address:
[mydomain.com...]
Jim
[zend.com...]
I recently converted a database driven system to use mod_rewrite and it was a royal pain in the you know what. I spent over 36 hours struggling to get the simplest things to work.
Finally seem to have gotten it though, and now that I have something that works, everything that was confusing me finally makes sense.
As if I didn't have enough to do, I've decided to write up an easy-to-understand mod_rewrite tutorial at some point to help people.. because I didn't find any good mod_rewrite information either.. too much trial and error.
The method you are using, so far as I know, will not help your search engine placement at all. The only thing I can think of that would help would be to change your file names to represent the content of each page.