문제

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