Cole
Cole

Reputation: 459

Setting .htaccess for 404 error

So, I new to .htaccess. My current .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /simpleblogsys/profile.php?username=$1

So I have created login and registration for the site I'm testing. If I type username after 'simpleblogsys/', it directs to the page. Example:

http://localhost/simpleblogsys/TestUser1

The problem is, if I put a slash the username and type something random, Like this:

http://localhost/simpleblogsys/TestUser1/blablabla

it loads the page without any scripts or stylesheets. I want to setup a Error 404 document if the page wasn't found. What should I do?

Upvotes: 0

Views: 79

Answers (1)

AllInOne
AllInOne

Reputation: 1450

Scripts and Stylesheets are not found most likely because you are calling them with a relative path...

js/whatever.js

you'll need to use a path from the root...

/assets/js/whatever.js

For the 404, if you are not seeing a valid username you can call:

header("HTTP/1.0 404 Not Found");

Upvotes: 1

Related Questions