.htaccess

software development

#1

Hi!
Usually I find answers to questions on message boards, but this time I’m totally stumped.

I’ve written quite a nice little site (given my complete lack of experience) but the last few touches are becoming very difficult.

I’d like to run html pages as php. The best advice I can find on the matter suggests using .htaccess and using the command AddType. Unfortunatley, this upset my php sessions, so I found an alternative, adding AddHandler to the .htaccess file and deleting the AddType line.

This seemed to be working quite fine, until ownership of one of my subfolders was transferred to apache, and I was unable to delete anything.

Other posts and Dreamhost support suggest this is the result of .htaccess calling mod_php. I need access to this subfolder as part of the functionality to the site, so I think this means I shouldn’t us .htaccess at all.

Does anyone have any suggestions as to how I could force html pages to execute the php, either not using .htaccess, or how to prevent .htaccess from upsetting my priviledges? - Thanks for your time :slight_smile:

ps - I originally had this over on general troubleshooting, but on second thought this forum sounded more appropriate - sorry!


#2

Shouldn’t your files just use the extension .php? Or do you really have to have php code in .html files?

Wholly - IS NOT MY PROMO CODE. Even worse, I don’t get any credit for it. Use WhollyMindless for full credit. I’m really disappointed in someone.


#3

I would prefer to have php code in the html files, but if there really isn’t a way to do it on Dream Host I’ll find a work around.

I’m hoping to have a menu button “log in” that becomes “go to your page”, if someone is logged in. Currently, I’m using a php session variable to determine if someone is logged in. For this function to work throughout the site (without forcing php to execute on an html page) every page in the site would need to be .php, which is a problem, given the need for the website to appear on google etc. (at least that is my understanding of the situation).

I’ll have to look into whether it would really matter if all the files were php - I thought it did, but maybe that has been resolved. Thanks :slight_smile:


#4

What addhandler line did you use in your .htaccess?

I use the following line to enable PHP code in .html files and still keep PHP running as CGI.

[color=#0000CC]AddHandler php-cgi .html .htm .php[/color]

or for PHP5…

[color=#0000CC]AddHandler php5-cgi .html .htm .php[/color]

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#5

Thanks Mark - I didn’t use the line you are suggesting, I used:

AddHandler application/x-httpd-php .php .htm .html

I’ll change it out and see if it works - Sounds like it should fix my problem though!

Thanks again!
Joline


#6

No problem, I hope it helps.

One other issue that you might run into; After making the changes to your .htaccess file, you will probably find that accesses to non-existent .html pages will generate ‘no input file’ errors instead of 404 errors. This has always been the case for non-existent .php pages, but having php handle .html pages extends this unwanted behavior to them as well.

The work around I use is to add the following to my .htaccess file and create a custom 404.php file, this solves the problem for both .html and .php files.

[color=#0000CC]RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /404.php [L][/color]

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#7

Thanks for showing up Mark.

Wholly - IS NOT MY PROMO CODE. Even worse, I don’t get any credit for it. Use WhollyMindless for full credit. I’m really disappointed in someone.


#8

No probs, luckily this particular subject is very fresh in my mind, as I recently did this to one of my domains.

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#9

thanks, i hadn’t even realized that switching to php-cgi had made 404s stop working. i put your rules in and it’s back to normal again!