tags:

views:

39

answers:

4

is there any problem with running html as php via htaccess? such as security or best practices ect. was doing this to make urls cleaner.

## run the following file types as php
Addhandler application/x-httpd-php .html .htm .rss .xml

well ideally id like to have my urls like

localhost/blog/posts/view.php?id=64 
to be 
localhost/projects/bittyPHP/bittyphp/posts/view/id-64 

but having trouble accomplishing that without routing everything to one file and having php run determine the paths. I guess this is my real question

+5  A: 

I would use mod rewrite.

Probably you do not need to run all html files as PHP, and if you have short_tags enabled "<?" in XML will give you trouble.

Goran Rakic
well ideally id like to have my urls like http://localhost/blog/posts/view.php?id=64 to be http://localhost/projects/bittyPHP/bittyphp/posts/view/id-64but having trouble accomplishing that without routing everything to one file and having php run determine the paths. I guess this is my real question.
David Morrow
then mod_rewrite is definitely your best bet
jackbot
+2  A: 

Keep in mind that you will run each and every of those files through the PHP handler then. If there is no PHP inside the files, the parser will still inspect them to see if there is any PHP in it. This adds some overhead, but it is likely neglectable in most setups.

Gordon
+2  A: 

Main issue I would say is performance. If you have a significant number of plain HTML files then you're creating unnecessary overhead by always running them through the PHP interpretter.

Best practice is not to do this, but use "friendly" URLS like mysite.com/item/123 and use mod_rewrite to convert them to mysite.com/displayitem.php?id=123 internally

Paolo
A: 

Like many people have already stated, mod_rewrite is the best solution for accomplishing friendly URLs.

Sitepoint has a decent guide to getting started with mod_rewrite.

Rexxars