NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page .htaccess redirect

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

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 06-30-2008, 01:03 PM THREAD STARTER               #1 (permalink)
SQLdumpster.com
 
Encenta.com's Avatar
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 573
Encenta.com has a spectacular aura aboutEncenta.com has a spectacular aura about
 




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?
????: NamePros.com http://www.namepros.com/programming/487777-htaccess-redirect.html
Many thanks
__________________
Encenta - Amazon Associates CMS
Last edited by Encenta.com; 06-30-2008 at 03:53 PM.
Encenta.com is offline  
Old 06-30-2008, 11:20 PM   #2 (permalink)
i love automation
 
xrvel's Avatar
Join Date: Nov 2007
Location: xrvel.com
Posts: 1,620
xrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant future
 





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, 02:17 AM THREAD STARTER               #3 (permalink)
SQLdumpster.com
 
Encenta.com's Avatar
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 573
Encenta.com has a spectacular aura aboutEncenta.com has a spectacular aura about
 




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

Just some advice: do not choose 1and1 for web hosting
__________________
Encenta - Amazon Associates CMS
Encenta.com is offline  
Old 07-01-2008, 08:40 AM   #4 (permalink)
New Member
Join Date: Jul 2008
Posts: 2
rdouglas is an unknown quantity at this point
 



Greetings.
????: NamePros.com http://www.namepros.com/showthread.php?t=487777

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, 01:13 PM THREAD STARTER               #5 (permalink)
SQLdumpster.com
 
Encenta.com's Avatar
Join Date: Jun 2005
Location: West Sussex, UK
Posts: 573
Encenta.com has a spectacular aura aboutEncenta.com has a spectacular aura about
 




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
__________________
Encenta - Amazon Associates CMS
Encenta.com is offline  
Old 07-01-2008, 04:19 PM   #6 (permalink)
New Member
Join Date: Jul 2008
Posts: 2
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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 06:05 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger