Home > Software design >  How can I handle in PHP a subfolder's index.php as main index.php
How can I handle in PHP a subfolder's index.php as main index.php

Time:04-09

I read this question: How to set an index page in a subfolder. I want to make like this, I have these folders and files:

index.php
items/
items/index.php

and I want, when I search for "items/general", then items/index.php handles it, not index.php. I tried to make a .htacces file in /items/.htacces, with this:

RewriteEngine On

RewriteRule ^/?$ items/index.php [L]

BUT when I search for "items/general", it gives a 404 error, like this:

Not Found

The requested URL was not found on this server.

(and my items/index.php includes a code to send html to all request)

Why doesn't works it?

CodePudding user response:

you can use something like that :

  RewriteRule  items/ items/index.php [L]

if you want a genaric rule /any-folder/any-file.php to /any-folder/index.php

  RewriteRule  (\w )/ $1/index.php [L]
  • Related