Reputation: 4561
I have the following file/folder structure for my site:
index.php
games.php
/category-games
/category-games/game-1.php
/category-games/game-2.php
The file games.php
is supposed to be a category homepage for /category-games/
. Is there any way to make this page show when someone visits mysite.com/category-games/
? I tried to put the page into the folder and called it index.php but I guess that's not working.
Probably need to do this via .htaccess. Anyone can help me with this? Right now if anyone tries to access mysite.com/category-games/
its going straight to 404.
Cheers!
Upvotes: 3
Views: 4598
Reputation: 129
Well, if you are thinking about in a organize and systematic coding, then I would like to suggest you to use PHP Routing library. There are many ready mate routing classes available. If you want to use that, surely it will help you to make your code more organized way.
For example, if you want to access mysite.com/category-games/
, behind the scene, routing will trigger your corresponding page.
Following code will try to access mysite.com/category-games folder but it will trigger out your-page.php file where user can see only mysite.com/category-games url, nothing else.
$router->any('/category-games', function(){
return 'your-page.php';
});
Isn't cool?
The list of routing library are-
Hope, will help you to do your project. TQ
Upvotes: 3
Reputation: 785631
Case 1: If /category-games/
has no .htaccess then place this rule in root .htaccess:
RewriteEngine On
RewriteRule ^category-games/$ games.php [L,NC]
Case 2: If there is a .htaccess inside /category-games/
then use this rule
RewriteEngine On
RewriteRule ^/?$ /games.php [L]
Upvotes: 5
Reputation: 409
Try making a new page called index.html under /category-games/ with the following contents:
<meta http-equiv="refresh" content="1;url=http://yoursite.com/category-games/games.php">
That would make index.html load by default but instantly redirect to games.php. The 1 is for how long to wait before redirecting. 1 is best so it doesn't overload your browser.
Toodles!
-HewwoCraziness
Upvotes: 1