Find htm or html files on (Linux) server

©

©®

I use a Linux/PHP hosting plan (not sure of the correct terninology - it
is not Windows/ASP based) for a website.

Is there a simple way that if someone types
http://www.mydomain.com/info.html that it would find the webpage
http://www.mydomain.com/info.htm (no "L" on the end) or vice versa: if
someone types http://www.mydomain.com/info.htm that it would find the
webpage http://www.mydomain.com/info.html (with "L" on the end)?

I am not even sure what this "procedure" would be called so hope someone
can help a newbie.
Thanks
 
M

Mike Duffy

©® said:
I use a Linux/PHP hosting plan (not sure of the correct terninology - it
is not Windows/ASP based) for a website.

Is there a simple way that if someone types
http://www.mydomain.com/info.html that it would find the webpage
http://www.mydomain.com/info.htm (no "L" on the end) or vice versa: if
someone types http://www.mydomain.com/info.htm that it would find the
webpage http://www.mydomain.com/info.html (with "L" on the end)?

I am not even sure what this "procedure" would be called so hope someone
can help a newbie.
Thanks

Despite that fact that I am one of the least knowledgable HTML "experts"
here, I can tell you that:

1) This is definitely NOT an HTML question. It is instead a question
relating to the exact server you are using. It is likely Apache, because
that is the most popular Unix-based server available. Find out if this is
the case, and take your question to an Apache newsgroup / forum. Note also
that you should be able to configure it to find a default extension. Using
your example, "http://www.mydomain.com/info" should get the user to
"http://www.mydomain.com/info.html" or "http://www.mydomain.com/info.htm",
whichever actually exists.

2) You could always use symbolic links within the Linux filesystem itself.
There are a number of approaches to use. I suppgest asking in a Linux
newsgroup / forum. Exactly how you do it depends on how often you intend to
modify your content and how you intend to back up your website.
 
J

Jonathan N. Little

©® said:
I use a Linux/PHP hosting plan (not sure of the correct terninology - it
is not Windows/ASP based) for a website.

Is there a simple way that if someone types
http://www.mydomain.com/info.html that it would find the webpage
http://www.mydomain.com/info.htm (no "L" on the end) or vice versa: if
someone types http://www.mydomain.com/info.htm that it would find the
webpage http://www.mydomain.com/info.html (with "L" on the end)?

I am not even sure what this "procedure" would be called so hope someone
can help a newbie.
Thanks

Agree this is not an HTML question, but with Apache there is a special
file .htaccess file that will fix this for you. (That is 'htaccess' with
a leading dot)

Firstly, name all you documents with full 4-letter 'html' extension. A
tip is to always use all lowercase and you will not have trouble with
case-insensitive Windows and and case-sensitive *nix & URLs

Secondly, create a plain textfile and name it ".htaccess" You will not
be able to do this on your Windows desktop because Windows will throw an
error that a file must have a filename and .htaccess looks to Windows as
just a file extension.

Work-a-rounds for this are:

1) Some hosting companies provide a .htaccess file editor in their
control panel.

2) Create the file directly on the server

3) Create a plain textfile in Windows, upload it an rename on server to
..htaccess

1 & 3 are the usual methods.

Thirdly, the .htaccess file should have this content:

# Start of .htaccess file
# Turn on the URL rewriting module
RewriteEngine on

# The rule to redirect all 'htm' requests to 'html'
RewriteRule ^(.*)\.htm$ $1.html [NC]
# End of .htaccess file

That is it. Any request, "foo.htm" or "foo.html" will bring you to
"foo.html"
 
N

Nico Schuyt

©® said:
I use a Linux/PHP hosting plan (not sure of the correct terninology -
it is not Windows/ASP based) for a website.

Is there a simple way that if someone types
http://www.mydomain.com/info.html that it would find the webpage
http://www.mydomain.com/info.htm (no "L" on the end) or vice versa: if
someone types http://www.mydomain.com/info.htm that it would find the
webpage http://www.mydomain.com/info.html (with "L" on the end)?

You need a .htaccess-file.
Basics: http://corz.org/serv/tricks/htaccess.php
Specific: http://corz.org/serv/tricks/htaccess2.php
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top