Php 如何进行这种访问
这就是我想要构建网站导航的方式。 我有不同的嵌套文件夹存储php文件。 在tv shows文件夹中,我存储系列名称文件。比如survivor.php和季节文件夹。 在季刊文件夹中,我存储季刊文件,如season-37.php和剧集文件夹。 在“剧集”文件夹中,我存储了所有的剧集名称,如Spidence-8.phpPhp 如何进行这种访问,php,.htaccess,Php,.htaccess,这就是我想要构建网站导航的方式。 我有不同的嵌套文件夹存储php文件。 在tv shows文件夹中,我存储系列名称文件。比如survivor.php和季节文件夹。 在季刊文件夹中,我存储季刊文件,如season-37.php和剧集文件夹。 在“剧集”文件夹中,我存储了所有的剧集名称,如Spidence-8.php 我想知道如何构造这种.htaccess来实现这种结构。您可以将所有文件存储在子目录中,如下所示: /tv-shows/survivor/ <a href="/tv-shows/
我想知道如何构造这种.htaccess来实现这种结构。您可以将所有文件存储在子目录中,如下所示:
/tv-shows/survivor/
<a href="/tv-shows/survivor/"></a>
/tv-shows/survivor/season-37
<a href="/tv-shows/survivor/season-37"></a>
/tv-shows/survivor/season-37/episode-8
<a href="/tv-shows/survivor/season-37/episode-8"></a>
要删除.php扩展名,可以添加以下内容:
tv-shows/
index.php (for /tv-shows)
survivor/
index.php (for /tv-shows/survivor)
season 1/
index.php (for /tv-shows/survivor/season-1)
episode-1.php (for /tv-shows/survivor/season-1/episode-1)
episode-2.php
...
season 2/
index.php
episode-1.php
episode-2.php
...
不过,我建议您只需移动到一个适当的框架,该框架具有路由功能,就像您要求一个mantainence噩梦一样
看看:,或者一个专用的PHP路由库。不过,一个框架会更好。到目前为止您尝试了什么?只是在RewriteRule^[A-zA-Z0-9]+$seriesname.php上使用普通的RewriteEngine?id=$1[NC,L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]