【发布时间】:2013-06-05 14:24:50
【问题描述】:
我正在使用我自己制作的 PHP CMS。它获取 $_GET 参数url 并将其转换为www.website.com/{url}。此 CMS 使用 $_GET 参数来获取文件。因此,如果 url 是 index,则 CMS 将搜索文件 index 并返回文件的内容。但现在,我正在扩展 CMS 以添加一个像 profile/{username} 这样的参数。我该如何扩展它?我希望我的 URL 显示 www.website.com/profile/{username}。我该怎么做呢?这是我当前的 htaccess:
RewriteEngine On
RewriteRule ^(|/)$ index.php?url=$1
RewriteRule ^([a-zA-Z0-9_-]+)(|/)$ index.php?url=$1a
这里是 TPL 系统。
public function addTpl() {
global $zip;
if(!isset($_GET['url']) || empty($_GET['url'])) {
$_GET['url'] = 'index';
}
if(file_exists('_zip/_templates/_front/'. $zip['Template']['Front'] . '/')) {
if(file_exists('_zip/_templates/_front/'. $zip['Template']['Front'] . '/' . secure($_GET['url']) . '.php')) {
ob_start();
include('_zip/_templates/_front/'. $zip['Template']['Front'] . '/' . secure($_GET['url']) . '.php');
$this->tpl .= ob_get_contents();
ob_end_clean();
} else {
die(zipError('File Not Found', 'The file <b>' . secure($_GET['url']) . '</b> could not be found. Please re-check the URL; If you were directed here using a link, please report that link.'));
}
} else {
die(zipError('Template Not Found', 'The template <b>' . $zip['Template']['Front'] . '</b> could not be found. Please check your configuration file for a mistake.'));
}
}
我还需要提供其他信息吗?我需要尽快完成这项工作,因此我们将不胜感激。
【问题讨论】:
-
我更新了主帖。我为 TPL 系统添加了 PHP。
-
“seo 友好的 url”是 SEO 行业犯下的神话。
-
@Dagon 也许是真的,但它们确实看起来更好,看到它们只会让你想拥有它们。
-
我在乎外观或网址就像我在乎我家钥匙的外观一样
-
你没有灵魂先生