我的网站具有以下文件/文件夹结构:
index.php
games.php
/category-games
/category-games/game-1.php
/category-games/game-2.php
文件
games.php
应该是/category-games/
的类别主页。当有人访问mysite.com/category-games/
时,有什么方法可以显示此页面?我试图将页面放入文件夹中,并将其命名为index.php,但是我想那不起作用。可能需要通过.htaccess进行此操作。有人可以帮我吗?现在,如果有人尝试访问
mysite.com/category-games/
,则直接进入404。干杯!
最佳答案
情况1:如果/category-games/
没有.htaccess,则将此规则放在根.htaccess中:
RewriteEngine On
RewriteRule ^category-games/$ games.php [L,NC]
情况2:如果
/category-games/
中存在.htaccess,请使用此规则RewriteEngine On
RewriteRule ^/?$ /games.php [L]
关于php - 如何在子文件夹中设置索引页,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31231919/