Question

I'm currently writing a PHP application, and I have always used frameworks and always worked in larger projects, but for this particular project I am doing neither. I've hit an issue where if I go to:

http://localhost/project

It runs the index.php file fine, but if I wanted to go to

http://localhost/project/test

I'd still want it to run the index.php file, and work out what to do with the 'test' part from there. Instead I'm getting a 404. How do I go about this?

I'm using Apache as my server, is it something I need to change in the .htaccess file? I'm pretty new to editing that file and have found most tutorials haven't said how to do this, but it seems like a pretty integral thing

edit:

This is what my htaccess currently looks like

Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
#  Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Était-ce utile?

La solution

Try to change your .htaccess file into :

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)(.*)/?$ index.php

as initial solution to check if it works

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top