Skip to content

404 for other routes except index #454

Answered by LebToki
eokwukwe asked this question in Q&A
Discussion options

You must be logged in to vote

It sounds like you need to set up URL rewriting in your project. This will allow your web server to redirect requests for specific URLs to the appropriate PHP file.

Here's how you can set up URL rewriting using Apache and a .htaccess file:

Create a new file named '.htaccess' in the root directory of your project.
Add the following code to the file:


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Save the file and try accessing your
demo.test/contact
or
demo.test/about

pages again.

This code tells Apache to enable URL rewriting, and to redirect all requests that are not for existing files or directories to
inde…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
3 replies
@eokwukwe
Comment options

@R0ck3n
Comment options

@AKMimi
Comment options

Answer selected by eokwukwe
Comment options

You must be logged in to vote
3 replies
@LebToki
Comment options

@eokwukwe
Comment options

@LebToki
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants