Forum Moderators: phranque

Message Too Old, No Replies

Modify the httpd.conf file or the .htaccess file?

I'm not sure what the difference is.

         

fjpapaleo

1:53 pm on Nov 4, 2005 (gmt 0)

10+ Year Member



I may have goofed. I just leased a managed server which doesn't give me root access to get to the httpd.conf file . I know I can still do a rewrite with the htaccess file but does it have the same capabilities? It seems the more advanced users here prefer configuring the apache server with the httpd.conf. As I don't have access to it I can't really tell what the advantage is.

I basically want to make friendly URL's. As I understand it I need to save my php files as html and tell the server to parse them as php. Something like:
RewriteRule ^([a-z]+)\.html$ /index.php?$1 [R,L]?

But I also need to replace part of the string like:
(?sortfield=&sortby=&search_fd3=) with a simple dash of slash. Is this all possible with htaccess or should I start over and get a server with root access?

I know this is becoming more and more important with the SE's and I'd like to get it right. Any help is much appreciated. Thanks.

jdMorgan

4:20 pm on Nov 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't need a rewrite to parse html for included PHP code. Just tell the server to do that:

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

added to httpd.conf or to .htaccess will enable the server to parse html files for php.

The difference between httpd.conf and .htaccess is one of power and scope. The documentation for each Apache directive states where it can be used, and some are restricted (for security and administration reasons) to httpd.conf. Also, further restrictions can be configured in httpd.conf to enable or disable procesing of certain directives in .htaccess.

You can solve the current problem as stated above. If you run into a problem that cannot be solved in .htaccess, you could ask the hosting provider to change your httpd.conf for you. Some will do this, and some won't, so you may want to inquire now, just to be sure.

Jim

fjpapaleo

4:45 pm on Nov 4, 2005 (gmt 0)

10+ Year Member



Thanks Jim.

From what I've been reading, if I'm understanding it right, the header information is first sent to the server where it is read by the httpd.conf and than translated into its filename. If you use .htaccess the request must go to the server than to the .htaccess file and back to the server to be read again. Of course this all only takes a split second but on a large site with a lot of URL manipulation wouldn't this be a potential problem?

jdMorgan

4:59 pm on Nov 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's all relative, and dependent on your server's CPU, memory, disk speed, etc. So, it's hard to say how 'big' a site would have to be to notice a problem. Besides, if you're using PHP or any other scripting language, that will have far more impact than native server operations.

If you're getting 100,000 uniques per day, then there might be some impact. Below that, I doubt it.

Jim

fjpapaleo

5:13 pm on Nov 4, 2005 (gmt 0)

10+ Year Member



Thanks again Jim.

If I get 100,000 hits a day I'll buy three servers :)