Website help/error

html
javascript
css

#1

My website does not seem to be working with Style.css, I have tried rewinding the project back to a point where it was working normally, and still, it does not want to load the style.css file for some reason. Any ideas on what might be happening?

Project name is: Time-Desert

I have also noticed that it does not recognise pages that are on the project


#2

Anyone able to help yet?


#3

Hey @Callum-OKane the “correct” solution depends on how you want things to work here.

Your project is mostly set up to use the Express static middleware. If you change your loader.js file’s app.use(express.static) call to point to the page directory and move your css and js files into that directory everything should work as you expect.


#4

Ok, is there anyway, I can have a glitch.json file running, and have package.json running aswell?

EDIT: I have also tried the solution for having express.static point to the page dir, but the problem still seems to be happening for me.


#5

Glitch uses either glitch.json or package.json to configure the app type; if you have both, only glitch.json will be processed.

Your project is serving your style.css and script.js files as expected now, but your references to them in your html page are off. Since everything’s being served from the root now, you can just use the filenames in the src attributes.


#6

Ok, And how can I use a glitch.json file to load a javascript file to make express work, because if the website pages are inside a folder, I need to have express running so it can find the html file I want to have load.


#7

Strictly speaking, for what your project’s doing right now you don’t need Express, and even if you want to use it for other routes, you don’t need the app.get('/'...) method at all if you were to rename home.html to index.html - Express would serve index.html at the base route using the static configuration.

Further, if you want to use Express then you want to use package.json, not glitch.json. The presence of package.json tells Glitch to treat the project as a Node project which is what you want in this case it seems to me. You could do it with a glitch.json file, but you’d really be fighting against Glitch’s built-in functionality.

Is there a reason you want to use glitch.json?


#8

I want to have the glitch.json, for enabling the use of using .htaccess files.


#9

You can’t use both Node (for Express) and Apache (for .htaccess) in a convenient way. If you need .htaccess thenI’d suggest using Apache all the way through your project. However if most of what you need .htaccess for is implementing Basic Auth the way we’ve discussed in other threads, you can do so in Node with Express and https://www.npmjs.com/package/express-basic-auth.


#10

I am trying to use Htaccess, because I was told that It can be used to removed the file extension in url’s


#11

Ok, I got the glitch.json because I managed to have index.html redirect to /page.home.html. There is a start.sh file that is loaded from glitch.json with this code:

#!/bin/bash

.mysql/run-mysqld.sh &
.apache2/run-apache2.sh &

wait

And I keep getting this error in the logs, which I never got the last time I had the exact same file/code.

start.sh: line 4: .apache2/run-apache2.sh: No such file or directory

start.sh: line 3: .mysql/run-mysqld.sh: No such file or directory

EDIT: I think remixing this project would solve this.


#12

You can have the friendly urls you’re looking for using Express routing. For example, you can create a route for app.get('/contact') and have it render page/contact.html.

If you want to use the LAMP model from https://glitch.com/~lamp-poc you need to Remix from that project or copy over the content of the .mysql and .apache directories.


#13

yes, I have got it working the way I want it to work, do you know any good tutorials on how to use htaccess for removing the file extension in urls?

EDIT: Some how, deleting the old project messed up my domain again, can you check to see if catmaniabot.tk or any subdomain of that is connected to any project, and remove them all?


#14

Hey @Callum-OKane I think I pointed to a possible resource for friendly urls in htaccess over at HTaccess file not working.

I removed two catmaniabot.tk custom domains from a deleted project and one from the project under discussion here.


#15

Ok, thank you so much for all your help, I have got the domain and no file extensions working now. Hopefully, this is the final question, may I ask why this does not work?


<Files /page/adminPage.html>

  Require valid-user

</Files>

EDIT:
I have also got another problem, I have my nav bar:

<ul>
  <li><active href="homepage">Home</active></li>
  <li><a href="updates">Updates</a></li>
  <li><a href="discussion">Chat Area</a></li>
  <li><a href="contact">Contact Us</a></li>
  <li><d href="home">Admin Panel</d></li>
</ul>

and the css for it:

    ul {
      list-style-type: none;
      margin: 0;
      padding: 0;
      overflow: hidden;
      background-color: #333;
    }

    li {
      float: left;  
      border-right: 1px solid #bbb;

    }
    li:last-child {
      border-right: none;
    }
    li a {
      float: left;
      display: block;
      color: white;
      text-align: center;
      padding: 14px 16px;
      text-decoration: none;
    }

    /* Change the link color to #111 (black) on hover */
    li a:hover {
      background-color: #111;
    }
    li active {
     display: block;
     color: black;
     background-color: white;
     text-align: center;
     padding: 14px 16px;
     text-decoration: none;
    float: left;
    }


    li d {
      float: left;
      display: block;
      color: white;
      text-align: center;
      padding: 14px 16px;
      text-decoration: none;
    }

    /* Change the link color to #111 (black) on hover */
    li d:hover {
      background-color: #111;
    }

And I am trying to have the admin page appear right on the nav bar, but I cannot seem to do it, I also cannot seem to be able to click “Admin Panel” on the nav bar, even though I have a href for it as well. Any solutions?


#16

Why the valid-user specification isn’t working depends on what the rest of the .htaccess file looks like - this isn’t enough to go on to be able to tell what might be wrong.

As far as your links are concerned, from the snippet you provided above you’re not using an anchor tag for the Admin Page; I think you have the wrong tag specified. Also it seems like the address may be inconsistent based on what I’m seeing here.

I don’t think this is in the same project we were talking about before. If you want to provide your new project name I can take a look.


#17

I have changed the project name to Catmaniabot


#18

The specification in the Files directive matches only the basename of the file - the name of the file itself, regardless of path. Also, it’s better practice to wrap the filename to match in double-quotes. So a better, working Files directive would be:

<Files "adminPage.html" >
  Require valid-user
</Files>

That will match any files named adminPanel.html anywhere in your site. If you need to restrict it to just files in the /page directory you’ll need to add it instead of .apache2/apache2.conf because <directory> directives are not allowed in .htaccess.


#19

I have added this, and when I went to load the page, it did not ask me for verification. Is this definitely correct?
EDIT: It was correct, just needed adminPage.html and not adminPanel.html in the htaccess file


#20

Oops! Sorry about that!!