PDA

View Full Version : htaccess and html files



peterhufo
05-21-2011, 07:22 PM
I am ftping several .html files to the root directory of my domain. If I address one of these files so: "http//<domain nme>/<subdirectory name>/<file name>.html", I am presented with a totally unknown site! If I change the extension to ".php", the correct page is rendered. I am assuming that some htaccess file upstream has been coded without a reference to html pages and only php pages.

I am hoping that someone can help me create an htaccess page that I can put in the same directory as the html files that will solve this problem.

farcaster
05-21-2011, 08:56 PM
Would you post the links you are using. The one that takes it off to somewhere else, and the one that shows correctly.

peterhufo
05-22-2011, 03:16 AM
Unfortunately, this site is propriety for internal use only so I cannot display the actual links.

The best that I can show is that this link does not show the correct page but some other page:

http//<domain name>/<subdirectory name>/<file name>.html

and this one shows the correct page:

http//<domain nme>/<subdirectory name>/<file name>.php

but the extension .html is the what I want. There is not php in the file, it contains only html.

Basil
05-22-2011, 11:59 AM
If you think there's a problem with your htaccess file, then you should post its contents.

peterhufo
05-23-2011, 08:45 AM
If you think there's a problem with your htaccess file, then you should post its contents.

As I mentioned in my original post, I don't have an htaccess file in my directory and am seeking some help creating one. I have looked at the htaccess files "up stream" from my directory and it appears that these htaccess files are looking for php files only. I say this with the reservation that I am not an expert in htaccess coding and I may not be interpreting what I see correctly.

I believe that I need an htaccess file in my directory that says "html files are OK too".

Am I on the right track?

Basil
05-23-2011, 11:07 AM
If you are uploading files with a .html extension, and you cannot access them using that extension on the server, something is interfering with it.

.htaccess files apply to all directories below them, so if you have one in a higher directory it will still be affecting your files.

I think I incorrectly interpreted your original post because it's ambiguous as to whether you're changing the extension in the url or renaming the file itself. I assumed you were just switching the address and getting two different results, are you actually renaming the file on the server?

If the file contains php and has something other than .php for the extension, the server will not interpret the php and it will simply be output to the browser and rendered as text or html.

Do you want:
A) Only the .html extension, but still rendered as php
B) Accessible to the user from both .html and .php; a redirect from one to the other allowing either url to work
C) Something completely different

peterhufo
05-23-2011, 11:51 AM
If you are uploading files with a .html extension, and you cannot access them using that extension on the server, something is interfering with it.

.htaccess files apply to all directories below them, so if you have one in a higher directory it will still be affecting your files.

I think I incorrectly interpreted your original post because it's ambiguous as to whether you're changing the extension in the url or renaming the file itself. I assumed you were just switching the address and getting two different results, are you actually renaming the file on the server?

If the file contains php and has something other than .php for the extension, the server will not interpret the php and it will simply be output to the browser and rendered as text or html.

Do you want:
A) Only the .html extension, but still rendered as php
B) Accessible to the user from both .html and .php; a redirect from one to the other allowing either url to work
C) Something completely different

Sorry if my prior posts are ambiguous, perhaps this will make my intent clearer.

The file that is being uploaded is a pure html file and its extension is ".html". If does not contain any php code.

On this server, if I address the file thusly "http://<domain name>/<subdirectory name>/<file name>.html", by its correct name, some other file is rendered.

If I change the extension on the actual file from ".html" to ".php" and address it via "http://<domain name>/<subdirectory name>/<file name>.php", the file is correctly rendered.

But the file contains no php and I don't want the file to be processed by the php processor.

If I put the same file, with it's ".html" extension, on another server and address it via "http://<domain name>/<subdirectory name>/<file name>.html" the file is correctly rendered.

My belief is that I need put an htaccess file in my directory coded to tell Apache to render my .html file.

Basil
05-23-2011, 12:20 PM
From your description I believe you have an htaccess file in a higher directory causing these redirects. Putting a new htaccess file in the current directory will override it, but that's just treating the symptom and not the cause. I need to be able to see what is in any htaccess files above the directory.

It would also help if you would explain what you get instead of your file when you try to access it, rather than just say "some other file is rendered," especially if it's an error page.

farcaster
05-23-2011, 01:05 PM
If I put the same file, with it's ".html" extension, on another server and address it via "http://<domain name>/<subdirectory name>/<file name>.html" the file is correctly rendered.


Please explain this statement further. How can you put the file on another server and use the same URL?
It sounds to me like you are trying to host the domain on two different servers/hosts. Or I am totally misreading what you are saying.

peterhufo
05-23-2011, 01:11 PM
Please explain this statement further. How can you put the file on another server and use the same URL?
It sounds to me like you are trying to host the domain on two different servers/hosts. Or I am totally misreading what you are saying.

http://<new domain>/<new subdirectory>/<same file>.html"