SPA Sub Page Issue

#1

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
#2

the same with me

#3

Hi Brad
We are going to check this.

1 Like
#4

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

#5

@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

#6

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

#7

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.

#8

@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
#9

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

1 Like
#10

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