Server Administration
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesServer Administration

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 5th, 2008, 04:09 PM
sorensen21 sorensen21 is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Aug 2008
Posts: 2 sorensen21 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 24 sec
Reputation Power: 0
Apache - .htaccess to read one file (html to php)

Hello everyone...

I have searched the entire web and found you guys and I am hoping you can help me. I am a newbie to .htaccess but always willing to learn. We have one page on our site that is a .html file that needs to be read as php.

The file name is mywebsite.com/cmd.html. When I rename the page to cmd.php it works perfectly. The file HAS to stay as a cmd.html file name.

Here is what I have done so far:

- I have saved the .php file as a .html file.
- Created the following .htaccess file

<FilesMatch "^/cmd\.html$">
SetHandler php-script
</FilesMatch>

Then when I visit my webpage mywebsite.com/cmd.html it gives me one line of coding that displays as html and nothing else.

Do you have any idea how I can fix this problem?

Thanks,

Tyler

Reply With Quote
  #2  
Old August 5th, 2008, 04:48 PM
IAmALlama IAmALlama is offline
Me
Click here for more information. Click here for more information
Click here for more information
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 1,937 IAmALlama User rank is Private First Class (20 - 50 Reputation Level)IAmALlama User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 5 Days 1 h 54 m 18 sec
Reputation Power: 4
tried this yet?
Code:
<Files cmd.html> 
AddType application/x-httpd-php .htm .html 
</Files>

or even just rename it to cmd.php and use url rewrite:
Code:
RewriteRule ^cmd\.html$ cmd.php [L] 

Reply With Quote
  #3  
Old August 26th, 2008, 08:20 PM
sorensen21 sorensen21 is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Aug 2008
Posts: 2 sorensen21 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 24 sec
Reputation Power: 0
It worked with the following...

Code:
<Files cmd.html>
  ForceType application/x-httpd-php
</Files>


Now I need to add to the .htaccess file. I need to redirect our subdomain blog.mydomain.com to mydomain.com/blog. I can figure out how to redirect a page on the site using .htaccess but not a subdomain.

Any help?

Tyler

Reply With Quote
  #4  
Old October 3rd, 2008, 05:41 PM
simcornay simcornay is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 1 simcornay User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 58 sec
Reputation Power: 0
Pleeeease help me with this "pretty please"

Hi all,

Well I have KINDA the same problem but with NOT being able to read a directory.

I have a site with this as my .htaccess

#php_value error_reporting 0

#DirectoryIndex main.php

RewriteEngine On

RewriteRule video/([^/]+)?$ index\.php?video=$1 [L]

RewriteRule tag/([^/]+)?$ index\.php?tag=$1 [L]

RewriteRule tag/([^/]+)/([^/]+)?$ index\.php?tag=$1&page=$2 [L]

RewriteRule tag/([^/]+)/([^/]+)/([^/]+)?$ index\.php?tag=$1&page=$2&sort=$3 [L]

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

Now the problem is whenever I go to MYSITE/articles I get 404 each time, unless I change all the pages to .php, in this case over 200.


Is there anyway around this or do I need to change all the pages to php

Hope someone can help, it's driving me nuts lol.

thanks for any help in advance
simon

Reply With Quote
  #5  
Old October 11th, 2008, 12:59 AM
Nilpo's Avatar
Nilpo Nilpo is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Codewalkers Headquarters
Posts: 155 Nilpo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 27 m 30 sec
Reputation Power: 3
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
Quote:
Originally Posted by simcornay
Hi all,

Well I have KINDA the same problem but with NOT being able to read a directory.

I have a site with this as my .htaccess

#php_value error_reporting 0

#DirectoryIndex main.php

RewriteEngine On

RewriteRule video/([^/]+)?$ index\.php?video=$1 [L]

RewriteRule tag/([^/]+)?$ index\.php?tag=$1 [L]

RewriteRule tag/([^/]+)/([^/]+)?$ index\.php?tag=$1&page=$2 [L]

RewriteRule tag/([^/]+)/([^/]+)/([^/]+)?$ index\.php?tag=$1&page=$2&sort=$3 [L]

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

Now the problem is whenever I go to MYSITE/articles I get 404 each time, unless I change all the pages to .php, in this case over 200.


Is there anyway around this or do I need to change all the pages to php

Hope someone can help, it's driving me nuts lol.

thanks for any help in advance
simon
It's sounds like you're having a problem with the default page setting. You would typically use something like this in your .htaccess file...
apache Code:
Original - apache Code
  1. DirectoryIndex filename.html
I see where you have this set to main.php, but you've got the line commented out so it's reverting to whatever your global setting might be.

What page are you trying to load when you type in a directory name? I'm assuming index.php? In this case, uncomment the line you have and change it like this...
apache Code:
Original - apache Code
  1. DirectoryIndex index.php
__________________
Don't like me? Click it.

Scripting problems? Windows questions? Ask the Windows Guru!

Stay up to date with all of my latest content. Follow me on Twitter!

Help us help you! Post your exact error message with these easy tips!

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesServer Administration > Apache - .htaccess to read one file (html to php)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek