I have a single-page application (SPA) website.
All of the content is loaded via Ajax, for eg.: .load('page/subpage3.html')
The url never changes at the top (which is by design, I want my visitors to always start browsing the site from the first page where I write the News).
From the menu the user can change the content of the site which is appearing under the menu. The content files are named with xyz.html so they appear formatted in my notepad++ and are in a subfolder. They have no header, no styles, no js files in their sources, since those are attached to my index.html. If a user is opening the site via the mysite.com domain, everything is appearing fine.
The (big) problem is that google is listing my content pages using their full path, like they are separate, complete working pages. But when a user is opening those links, only that content file is loaded, without any pictures, any css or js files, no menu, even the characters appearing wrong, since nothing is specified in these content files.
My question is, how could I force to "always open the index.html" instead, when clicking on (/typing) a content page's url. Those urls (my subpages - the content files) should be redirected to my domain name. Like I did with the 404 error handling.
Probably to solve the problem, the .htaccess file needs to be changed (which I have full access to, luckily). The site is running on Apache server.
Best I found is the next code, but I'm afraid to use/try it:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule . index.html [R=302,L]
because I don't know if it can break any in-site features (the menu, photo gallery, ...) and I am not sure if google will be able to search and list the matches fine after these changes or it will ignore those content pages cause of the redirect? (Or even if it will work, my page could get lower ranking?) I'd like to keep the google findings on the entire site the same as now. Thank you.