Forum Moderators: coopster

Message Too Old, No Replies

parse php as html - helpless for newbie

have looked and looked but I can't find what I need

         

bluecorr

10:32 pm on Jan 4, 2003 (gmt 0)

10+ Year Member



I have looked using the search function and looked in google as well on how to parse something like

[mydomain.com...]
[mydomain.com...]
[mydomain.com...]

out to something like

[mydomain.com...]
[mydomain.com...]
[mydomain.com...]

or something else, html only though

I am a big zero at servers and programming and most of the things I came across in my search were either too simple (making php just look html like file.php to file.html) or much more complicated strings.

Please, could someone take pity in me and help me out? :)

Thanks!

wruk999

11:18 pm on Jan 4, 2003 (gmt 0)

10+ Year Member



Hi Bluecorr,

is this something that you want to do on the fly, ie: when a user navigates to that page, it is returned as a plain html file,
or is it something which you want as a permanent thing, ie if a record is in a database with a value, you want a static page making for it?

Is it for the Search Engines benefit, or just to reduce load on the server.

I think that .htaccess ReWrite can be used, but dont know whether it works in the way you want it to. Some of the unix bods around here will be able to help you out no doubt.

details as to the use of the system could be useful.

Regards,
Will

andreasfriedrich

11:25 pm on Jan 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you have a look at those threads?

PHP vs HTML question [webmasterworld.com]
An Introduction to Redirecting URLs on an Apache Server [webmasterworld.com]

Andreas

bluecorr

9:31 am on Jan 5, 2003 (gmt 0)

10+ Year Member



*wruk999 - I had in mind a permanent thing. That thing is a forum and I wanted to make it plain html so it could be easily crawled by SE. For example this site, all URL's are html. Something like that. Server is using Apache.

*andreasfriedrich - thanks for the threads but they didn't much good. I understood some of DaveAtIFG's post although that doesn't touch the topic of php parsing as html. I tried understanding the Apache documentation but I got lost after the first section. Even tried sitepoint's threads on the same issue and same result.

I guess I have to give the idea up, I was able to learn and understand html, css but this apache and php thing is way over my head :(:(

Thanks for your time.

wruk999

11:25 am on Jan 5, 2003 (gmt 0)

10+ Year Member



Hi Bluecorr,

have a look at this page: [webmasterworld.com...]

In brief, SE's can spider URL's with a paramter, so yours:
/entry.php?show=2.1

will be able to be spidered successfully.

The system I talk about in the post referred to above, would not be good enough for this forum job (like yours), but the post just confirms what I have said about dynamic URL's. ;)

Good Luck, and if you need any more help, feel free to ask.:)

Regards,
Will

bluecorr

1:37 pm on Jan 5, 2003 (gmt 0)

10+ Year Member



Thanks for the reply. I guess I can sleep peacefully tonight knowing my new forum will be crawled :). Much appreciated again.

Birdman

2:00 pm on Jan 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Bluecorr,
To parse HTML as PHP, go to(or create) your .htaccess file which shoould be in your root(or public_html) directory and put this line in it.

AddType application/x-httpd-php .php .php3 .phtml .html

Then, you can use the rewrite engine to make it look like the paramaters are part of the filename.

RewriteEngine On
RewriteRule ^entry_(.*)\.html$ /entry.php?show=$1 [L]

I believe the above lines would successfully change your urls as you noted in your first post.

bluecorr

2:30 pm on Jan 5, 2003 (gmt 0)

10+ Year Member



I just tried what you suggested Birdman and I got this:

"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. "
:(

Birdman

2:56 pm on Jan 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you have an existing .htaccess file?

Also, did you try both suggestions above or just the first(addtype)?

wruk999

2:59 pm on Jan 5, 2003 (gmt 0)

10+ Year Member



Bluecorr,

if your needs were *purely* search engine related, then there is no need to HAVE to convert to standard html pages - as long as the pages only have one parameter, they will get spidered well!

If however it was to reduce load on the server, then Birdmans way will create more load (i think), so best to stick with your initial idea.

Birdman, is your way making all html files parse through the php parser, and then rewriting the pages into a standard html page?

Regards

andreasfriedrich

3:17 pm on Jan 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if your needs were *purely* search engine related, then there is no need to HAVE to convert to standard html pages

  1. There is a difference between convert[ing] to standard html pages and mak[ing] it look like the paramaters are part of the filename.
  2. This is because referrer and referent are not the same.
  3. Therefor a static looking URI may very well reference a dynamically created page.
  4. Only having static pages reduces the load on the server.
  5. It is a good idea and good programming practice to establish an interface between your script and the outside world in the form of human readable URIs.

Andreas

wruk999

3:22 pm on Jan 5, 2003 (gmt 0)

10+ Year Member



thanks andreas.

clear, concise info.

cheers :)

bluecorr

4:35 pm on Jan 5, 2003 (gmt 0)

10+ Year Member



Yes there was an existing htaccess file that had a redirect 301 line and some custom 404. I added both your suggestions. Tried it several times, added the lines to the existing ones, removed the old ones and put these 2 new ones instead. Same error. Could it be that the server is misconfigured?

I understand that the current urls are perfectly crawlable but as far as I have seen html files always rank higher than php ones, even if they have only one parameter. Maybe I'm wrong?

Birdman

4:39 pm on Jan 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



bluecorr,
my rewrite rule could be incorrect, but this line should allow you to use php in .html pages:

AddType application/x-httpd-php .php .php3 .phtml .html

Try adding just that line, then put a simple php echo statement on an .html page. Good luck!

bluecorr

3:30 pm on Jan 6, 2003 (gmt 0)

10+ Year Member



No Birdman, your rewrite rule wasn't wrong, server doesn't support mod_rewrite, just discovered that. Sorry about that.