[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 06-30-2008, 12:03 PM   #1 (permalink)
SQLdumpster.com
 
miseria's Avatar
 
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 545
205.50 NP$ (Donate)

miseria will become famous soon enoughmiseria will become famous soon enough


Smile .htaccess redirect

Hey. I would be very grateful if someone could help me with the following; I have a series of PHP files which I would like accessible as .html (e.g. index.html actually points to index.php). However, when trying to view fckeditor.html file, it's looking for fckeditor.php (and presents a "300 multiple choices" Bullcrap). Until switching to 1and1.co.uk hosting, it worked fine. Here is the .htaccess:

Code:
ErrorDocument 404 /404-page-not-found.html
#AddType application/x-httpd-php .php .php3 .phtml .html
AddType x-mapp-php4 .html

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*).html /$1.php [QSA,L]
The line causing the trouble is:

Code:
RewriteRule (.*).html /$1.php [QSA,L]
UPDATE: I think it may instead be the line:
Code:
RewriteCond %{SCRIPT_FILENAME} !-f
..not working. Surely, if the file doesn't exist, THEN do the rewrite. No?
Many thanks
__________________
!!!!!!! see something you like? Accepting offers for great affiliate websites !!!!!!!
Free Databases for your Website | All Things Playstation 3
Website Design Books | Music While You Work? | Computer Gadgets

Last edited by miseria; 06-30-2008 at 02:53 PM.
miseria is offline  
Old 06-30-2008, 10:20 PM   #2 (permalink)
i love automation
 
xrvel's Avatar
 
Join Date: Nov 2007
Posts: 1,409
987.78 NP$ (Donate)

xrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud of


Smile

You can try this
Code:
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*).html $1.php [QSA,L]
xrvel is offline  
Old 07-01-2008, 01:17 AM   #3 (permalink)
SQLdumpster.com
 
miseria's Avatar
 
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 545
205.50 NP$ (Donate)

miseria will become famous soon enoughmiseria will become famous soon enough


Thanks but now PHP files do not run with .html.

Just some advice: do not choose 1and1 for web hosting
__________________
!!!!!!! see something you like? Accepting offers for great affiliate websites !!!!!!!
Free Databases for your Website | All Things Playstation 3
Website Design Books | Music While You Work? | Computer Gadgets
miseria is offline  
Old 07-01-2008, 07:40 AM   #4 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 2
0.00 NP$ (Donate)

rdouglas is an unknown quantity at this point


Greetings.

You can configure your apache to process php in .html files a much easier way than using rewrites and .htaccess

Just edit your config file for the php apache module and add .html to the end of the line. Here is an example.

Code:
AddType application/x-httpd-php .php .phtml .php3 .html
The file is usually called
Code:
php.conf
and is located in your apache directory.

Regards,
Richard.
rdouglas is offline  
Old 07-01-2008, 12:13 PM   #5 (permalink)
SQLdumpster.com
 
miseria's Avatar
 
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 545
205.50 NP$ (Donate)

miseria will become famous soon enoughmiseria will become famous soon enough


Hi Richard. Thanks for your help and welcome to Namepros.

I think this will be the likely solution (using the .htaccess though and not the conf file). The problem is; with 1and1, you have to use an alternate method which is a bit of a snag:

Code:
AddType x-mapp-php4 .html
But using this method would mean I'd have to rename all my current .php files to .html
__________________
!!!!!!! see something you like? Accepting offers for great affiliate websites !!!!!!!
Free Databases for your Website | All Things Playstation 3
Website Design Books | Music While You Work? | Computer Gadgets
miseria is offline  
Old 07-01-2008, 03:19 PM   #6 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 2
0.00 NP$ (Donate)

rdouglas is an unknown quantity at this point


Perhaps I did not understand what you wanted to do. I thought you wanted to execute PHP from .html files ?

If you want your .php to be used as .html, then rename them to .html and 301 the old .php to the .html and you're done. Keep it simple and don't confuse the user or the SE's.

- Richard
rdouglas is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 06:38 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85