Cristiano Posted October 18, 2018 Share Posted October 18, 2018 I created this lean and mean site: http://cristianopi.altervista.org/as/ If a visitor load any page other than index.html, the index is not loaded; I want that the index is always loaded. I can put a link to the index in each page, but is there a better way to do that? Link to comment Share on other sites More sharing options...
dsonesuk Posted October 18, 2018 Share Posted October 18, 2018 The index.html is usually the home page for the the domains root directory, anyone entering http://cristianopi.altervista.org/ should land on a index.htm|htm|aspx|php, or , default.htm|htm|aspx|php file. any link using href="/" would take to that root directory and index or default file. Anyone clicking on google link, or saved link to another page on your site, should not be redirected to somewhere they didn't want go UNLESS that page did not exist anymore. Link to comment Share on other sites More sharing options...
Cristiano Posted October 18, 2018 Author Share Posted October 18, 2018 Suppose that someone, after a search on google, finds the link: http://cristianopi.altervista.org/as/pred_irnss-1h.html. If he clicks the link, the page is loaded but he doesn't see the index, but he could be also interested in the other pages. For that reason I need to automatically load also the index.html page. Link to comment Share on other sites More sharing options...
Funce Posted October 18, 2018 Share Posted October 18, 2018 Have you tried using an .htaccess file? https://stackoverflow.com/questions/17709500/how-to-redirect-all-pages-only-to-index-html-using-htaccess-file-and-not-redirec Link to comment Share on other sites More sharing options...
dsonesuk Posted October 18, 2018 Share Posted October 18, 2018 What you would normally do is use a server language such as php, create a single page with navigation only, with all links with home/index link page first. With this single nav page this can be included in all the other pages, just by using <?php include 'nav.php'; ?> the navigation would be inserted into that page, and any other php page using that code. amending the nav.page, means that amendment would instantly show that amendment for all page using that code also. This gives all the links to other page, on each page, i think this is what you are looking for? yes! Link to comment Share on other sites More sharing options...
Cristiano Posted October 18, 2018 Author Share Posted October 18, 2018 57 minutes ago, Funce said: Have you tried using an .htaccess file? https://stackoverflow.com/questions/17709500/how-to-redirect-all-pages-only-to-index-html-using-htaccess-file-and-not-redirec I created the site http://cristianopi.altervista.org/as_old/ and the file .htaccess: RewriteEngine on RewriteCond %{REQUEST_URI} !^as_old/index.html$ RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$ RewriteRule .* /as_old/index.html [L,R=302] but when I click a link on the index page, the index page itself is loaded into the iframe (instead of the page in the link). Link to comment Share on other sites More sharing options...
Cristiano Posted October 18, 2018 Author Share Posted October 18, 2018 57 minutes ago, dsonesuk said: [...] This gives all the links to other page, on each page, i think this is what you are looking for? yes! It's well beyond my current skill level. Link to comment Share on other sites More sharing options...
Funce Posted October 18, 2018 Share Posted October 18, 2018 20 minutes ago, Cristiano said: I created the site http://cristianopi.altervista.org/as_old/ and the file .htaccess: RewriteEngine on RewriteCond %{REQUEST_URI} !^as_old/index.html$ RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$ RewriteRule .* /as_old/index.html [L,R=302] but when I click a link on the index page, the index page itself is loaded into the iframe (instead of the page in the link). I see, you'll probably need a server side language like PHP instead. I've misunderstood your issue. Link to comment Share on other sites More sharing options...
dsonesuk Posted October 18, 2018 Share Posted October 18, 2018 (edited) There is a html/JavaScript option, I wouldn't personally use it, in preference to server side script option https://www.w3schools.com/howto/howto_html_include.asp As I know server side would always work, while html/JavaScript relies on JavaScript being enabled. Edited October 18, 2018 by dsonesuk Link to comment Share on other sites More sharing options...
Cristiano Posted October 19, 2018 Author Share Posted October 19, 2018 I'm not sure whether to use the include method or an index link inside each page (but probably the latter). Anyway, thanks to both of you. Link to comment Share on other sites More sharing options...
dsonesuk Posted October 19, 2018 Share Posted October 19, 2018 You usually have the website logo linking to index. page, as well as a nav link. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now