.html on address bar

  • LindBlad
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61

Post 3+ Months Ago

This has to be the stupidest question ever but i cant figure it out cause i dont do websites that much, so sorry about this:

What am i doing wrong when i get the .html on address bar and not like here at Ozzu for example ....com/forum/
I mean, when i click the links on the website, the links end up like this: ..../etusivu.html
This is how my links look in the code:

Code: [ Select ]
<a href="yhteystiedot.htm">YHTEYSTIEDOT</a>


I tried to find it out from other simple websites but could not.
Thanks for any help :)
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Mustafa_Aslan
  • Beginner
  • Beginner
  • Mustafa_Aslan
  • Posts: 38

Post 3+ Months Ago

I really did not understand your question but just guessing.

Are your trying to get rid off the .html (or .php etc) part of the url in address bar?
Moderator Remark: Removed link, please post solutions here
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

If you don't want an extension on the end of a link, then you would make a directory on your website. For example you could make a directory called:

forum

Then you would make sure you have an index.html file in that folder as that would be the default file that is shown when you request that folder. So if at that point you linked to:

Code: [ Select ]
<a href="http://www.yoursite.com/yhteystiedot/">YHTEYSTIEDOT</a>


It would automatically load the index.html file in that folder. Alternatively you could do complicated htaccess work if you are needing to dynamically do this sort of stuff with PHP scripts, but you didn't mention any of that so I am thinking you are just looking for a straightforward simple answer here.
  • LindBlad
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61

Post 3+ Months Ago

Bigwebmaster wrote:
If you don't want an extension on the end of a link, then you would make a directory on your website. For example you could make a directory called:

forum

Then you would make sure you have an index.html file in that folder as that would be the default file that is shown when you request that folder. So if at that point you linked to:





Thanks Bigwebmaster! This was exactly what i was asking, but i did not quite understand it yet :/
Does this mean that i have to make a new folder for every page i have on my website? And always save all the pages as "index.html"?

[testing...]

This seemed pretty complicated way to do it (for me who always saves everything to one folder), but wow, it worked :D
I actually didnt have to put the full URL cause it worked like this:
Code: [ Select ]
<a href="yhteystiedot/">yhteystiedot!</a>


Thanks again Bigwebmaster!!! :)
  • Mustafa_Aslan
  • Beginner
  • Beginner
  • Mustafa_Aslan
  • Posts: 38

Post 3+ Months Ago

You need to work on .htaccess file then.

Code: [ Select ]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
# Replace html with your file extension, eg: php, htm, asp
  1. RewriteEngine on
  2. RewriteCond %{REQUEST_FILENAME} !-d
  3. RewriteCond %{REQUEST_FILENAME}\.html -f
  4. RewriteRule ^(.*)$ $1.html
  5. # Replace html with your file extension, eg: php, htm, asp


If you want a tailing slash to be added then

Code: [ Select ]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/$ $1.html

# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
  1. RewriteEngine on
  2. RewriteCond %{REQUEST_FILENAME} !-d
  3. RewriteCond %{REQUEST_FILENAME}\.html -f
  4. RewriteRule ^([^/]+)/$ $1.html
  5. # Forces a trailing slash to be added
  6. RewriteCond %{REQUEST_FILENAME} !-f
  7. RewriteCond %{REQUEST_FILENAME} !-d
  8. RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
  9. RewriteRule (.*)$ /$1/ [R=301,L]
  • Mustafa_Aslan
  • Beginner
  • Beginner
  • Mustafa_Aslan
  • Posts: 38

Post 3+ Months Ago

Forgot to mention:

When you link for exaqmple about.html you may just use <a href="http://yourdomain/about>About</a>
  • LindBlad
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61

Post 3+ Months Ago

Thank Mustafa_Aslan, but i am too amateur for that kind of stuff :/ But i keep this as a reference if i want to learn to use it some day :)
  • Mustafa_Aslan
  • Beginner
  • Beginner
  • Mustafa_Aslan
  • Posts: 38

Post 3+ Months Ago

It is not difficult at all. Just connect to your server with any FTP client software (like FileZilla or cuteFTP) and go to your domain root folder, there should be a file called .htaccess, right click on it and choose view/edit, and copy&paste the code above into that file. You are done.

If you don't have .htaccess file in your root directory:
Create a text file in your local computer, name it htaccess.txt. Copy&Paste the code above into that file. Upload file to your domain root and change the file to .htacsess (notice the dot at the beginning).

You are done.
  • LindBlad
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61

Post 3+ Months Ago

Maybe i will try it one day, thanks :)
  • Mustafa_Aslan
  • Beginner
  • Beginner
  • Mustafa_Aslan
  • Posts: 38

Post 3+ Months Ago

you are welcome :)
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Quote:
Does this mean that I have to make a new folder for every page I have on my website? And always save all the pages as "index.html"?


Yes that would be correct. If you plan to do this for thousands and thousands of files with a .html extension that you want to appear as directories and you don't want to convert each one over for that format by placing them all in new directories and changing the filename to index.html, then Mustafa's solution would probably work better.
  • LindBlad
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61

Post 3+ Months Ago

Mustafa_Aslan wrote:
You need to work on .htaccess file then.

Code: [ Select ]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
# Replace html with your file extension, eg: php, htm, asp
  1. RewriteEngine on
  2. RewriteCond %{REQUEST_FILENAME} !-d
  3. RewriteCond %{REQUEST_FILENAME}\.html -f
  4. RewriteRule ^(.*)$ $1.html
  5. # Replace html with your file extension, eg: php, htm, asp


If you want a tailing slash to be added then

Code: [ Select ]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/$ $1.html

# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
  1. RewriteEngine on
  2. RewriteCond %{REQUEST_FILENAME} !-d
  3. RewriteCond %{REQUEST_FILENAME}\.html -f
  4. RewriteRule ^([^/]+)/$ $1.html
  5. # Forces a trailing slash to be added
  6. RewriteCond %{REQUEST_FILENAME} !-f
  7. RewriteCond %{REQUEST_FILENAME} !-d
  8. RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
  9. RewriteRule (.*)$ /$1/ [R=301,L]



I have tried these now but the .html is still showing in the end of the address :(
Could it be that the server doesnt support this .htaccess thingy?

(I tried to post my website address but looks like something changed here)
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Where are you hosted, do you know if you are on a Linux machine or Windows? Is the server running Apache? .htaccess files are specific to Apache. Also even if the server configuration is right with the hardware it is also possible that your webhost might not allow you to use them, although the majority of them do these days.
  • LindBlad
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61

Post 3+ Months Ago

Bigwebmaster wrote:
Where are you hosted, do you know if you are on a Linux machine or Windows? Is the server running Apache? .htaccess files are specific to Apache. Also even if the server configuration is right with the hardware it is also possible that your webhost might not allow you to use them, although the majority of them do these days.


I tried to find out but the hosting i have is very cheap, and i only found that it doesnt support PHP, Perl, CGI.

I tried the .htaccess file on another website i made that is on better hosting and it gave me this:

Quote:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

Post Information

  • Total Posts in this topic: 14 posts
  • Users browsing this forum: No registered users and 74 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.