Forum Moderators: coopster

Message Too Old, No Replies

What do you think of this MOD REWRITE alternative?

Will this alt method still hinder SERP?

         

brucec

9:19 pm on Jul 8, 2004 (gmt 0)

10+ Year Member



I don't mean to vent. I have been a programmer for over 10 years and have yet to find decent material on mod rewrites. Not to offend anybody. Even the Apache web site is confusing on this. What is a non-canonic web address anyway?

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.

victor

10:13 pm on Jul 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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&param2=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).

phpmaven

5:50 am on Jul 9, 2004 (gmt 0)

10+ Year Member



One more thing to keep in mind is that you need to use the header() function in PHP to issue the proper headers or a browser or worse still a search engine spider, will still get a 404 error header.

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.

coopster

7:01 pm on Jul 9, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



brucec, no offense taken ;) Your post does not have any overtones of venting or disgruntled attitude, it was well-written and I can understand your frustrations. Apache's mod_rewrite documentation is lacking. It can involve a lot of trial and error to get things working and to reach a level of understanding that makes it fun to use. Wanna make your million? Learn it inside and out and write a book on it.

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?

bcolflesh

7:04 pm on Jul 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is a non-canonic web address anyway?

Canonical address:
[something.mydomain.com...]

Non-Canonical address:
[mydomain.com...]

jdMorgan

7:18 pm on Jul 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using a ErrorDocument 404 handler to redirect to a script is not a good general solution, and causes known problems. See this thread [webmasterworld.com] for a very simple mod_rewrite method.

Jim

dak142

2:50 am on Aug 4, 2004 (gmt 0)

10+ Year Member



I use PHP to make my dynamic pages look static to serach engines. I works VERY well when you are only passing one parameter. I read over the below page and have it up and running in 1 hour. If you have any questions on it just ask, I will be more than happy to help. If you are fluent in PHP, I doubt you will need any help thought, good luck.

[zend.com...]

TheBlueEyz

11:07 am on Aug 5, 2004 (gmt 0)

10+ Year Member



Just wanted to say, I totally sympathize on mod_rewrite.

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.

vincevincevince

12:30 pm on Aug 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Whilst I do sympathise with your mod_rewrite problems, I feel it is my duty to add this:

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.