SPA Sub Page Issue

I managed to get my navigation working following the tutorial. And it seems to work just fine. Except if you go directly to a sub page it comes up with a 404 error.

http://kopar.workbcpg.ca/ works just fine …

http://kopar.workbcpg.ca/about comes up with a 404 error …

Also, if you refresh the page when on a sub page it comes up with a 404 error.

Did I do something wrong?

1 Like

the same with me

Hi Brad
We are going to check this.

1 Like

Thanks, I don’t want to use SPA technique if this is an issue.

@brad, I am sure that you have made a mistake somewhere. Please try https://pleysier.com.au/about and compare the source code with that of the (so-called) working copy of http://kopar.workbcpg.ca/about.

Make sure that the links in the navbar look similar to

<div class="collapse navbar-collapse justify-content-end" id="navbar1_collapse">
   <div class="navbar-nav">
        <a class="nav-item nav-link active" href="./">Home</a>
        <a class="nav-item nav-link" href="./about">About</a>
        <a class="nav-item nav-link" href="./services">Services</a>
        <a class="nav-item nav-link" href="./contact">Contact</a>
   </div>
</div>

and the routing in .htaccess similar to

Wappler routing

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?(?:/)?$ index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?(?:/)?$ index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?about(?:/)?$ index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?services(?:/)?$ index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?contact(?:/)?$ index.php [QSA,NC,L]

End Wappler routing

I had a little bit of drama with dynamic stuff, but it all working well and standard links are no worries.
http://testing2019.thegunnery.com.au/index.php

Thanks @ben, my code matches up with yours but still having this strange issue. Hope a cause is found before I get to far into the site and have to redo it.

@brad, as a total point of interest have you tried adding to the first line of your .htaccess file the directive to follow symbolic links as maybe your httpd.conf file is configured a little different. Try adding as line 1
Options +FollowSymLinks

Not 100% sure if it will do much but cant really harm too much either.

2 Likes

Thanks @psweb! I have no idea what that line of code does but it seems to work as it should now.

1 Like

Glad it worked, lol, you can look up apache symbolic links if you want more information, however most clean apache builds i have made myself i would have that already setup in the httpd.conf file as it is better for server security.
@patrick would probably have to add that as a default to the .htaccess file for others if they have a similar issue.

3 Likes