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
有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top