0

When I load my website the first page that is shown is www.website.com/index.html. This is what you can see in your adressbar. When I open a second page on the website www.website.com/page1.html is shown.

Now how can I change www.website.com/index.html to www.website.com/ and the other pages just to www.website.com/page1 instead of www.website.com/page1.html

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
user3644837
  • 335
  • 2
  • 3
  • 8
  • 3
    You need to provide information about which environment your website is hosted within. Without this information it will hard for anyone to answer. – Lee Taylor Jan 06 '15 at 18:37
  • see this [link](http://stackoverflow.com/a/21617605/3168859)..might help you provided you are running under Apache server.. – Lal Jan 06 '15 at 18:41
  • Just a guess but you'd probably want to reference your API for the URL instead of going to index.html, first. But, if you're wanting to take the .html off of the url then you can just manipulate the appSettings.Url (as a string) to take off the .html – user1789573 Jan 06 '15 at 18:41
  • 1
    @Lal That's assuming the OP is running under Apache. This isn't hinted at in the question. – Lee Taylor Jan 06 '15 at 18:41
  • ya..i just edited my comment..@lee – Lal Jan 06 '15 at 18:43

3 Answers3

0

I assume the website uses only plain html. If so, you can create another folder called page1 and inside create an index.html. This way you will be able to access the new index.html (the one inside page1 folder) just by pointing your browser to:

www.website.com/page1/

This works if the website is hosted on a server like Apache.

Other option is to redirect the request. Please have a look at http://httpd.apache.org/docs/2.4/rewrite/remapping.html

panagdu
  • 2,133
  • 1
  • 21
  • 36
0

try this method

 <script type='text/javascript'>
      if(history.replaceState) history.replaceState({}, "", "/");
      </script>  

Note : where / is the path u want to show.

OR

you have to add this to your .htaccess file

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

it shows the url like mysite.com no matter which link i have clicked. but i have a problem with this code while reloading the page the complete url with query string blink into address bar.

sanoj lawrence
  • 951
  • 5
  • 29
  • 69
0

Heres what I do that works because .htaccess files have always caused me issues.

Step 1: Create a folder with what you want to be shown in the browser (website.com/foldername)

Step 2: Put a index.html inside of that folder

Step 3: Change your pages links and linked files to work with the folders (../foldername/index.html)

Joe Scotto
  • 10,936
  • 14
  • 66
  • 136