因此,我使用Concrete5作为CMS,并试图重写一个已经重写的url。
所以,我有一个url http://url.com/index.php?cID=144&id=4,它重写到http://url.com/rengas?id=1。
但是,我想重写它到http://url.com/rengas/1,到目前为止,我还无法做到这一点。
这是我的htaccess:
# -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
# -- concrete5 urls end --
RewriteEngine On
RewriteRule ^rengas/([^/]*)$ /index.php?cID=144&id=$1 [L]正如您可能会问的那样,我使用http://www.generateit.net/mod-rewrite/index.php生成了这个规则,它做得很好,但是这次它让我失望了。
发布于 2014-03-11 10:16:31
假设您的单个页面名为testpage.php,位于root/ single _pages/testpage.php
通过创建控制器,可以在最后一个斜杠之后捕获数据。
例如: mysite.com/testpage/123
您的控制器文件位于:root/ controller /testpage.php。
控制器的内容(为了使其适应您的代码,不要忘记调整类名,在您的示例中是...rengasController扩展.) ==
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class testpageController extends Controller {
public function view($id){
//here you can do anything with the captured id.
// here you can set the id to give it to your single page using following code:
$this->set('id', $id);
// the code above will make a variable $id to use in the code of the single page
}
}
?>我知道上面的解释可能有点难理解,所以这里有一些链接可以更好地理解Concrete5中的MVC (单页和控制器)系统:
http://www.concrete5.org/documentation/recorded-trainings/single-pages/basic-application-development-part-one/ (请参见创建单个页面控制器和视图)
http://www.concrete5.org/documentation/how-tos/developers/basic-mvc-in-concrete5/ (参见单页控制器)
下面是我编写的一个示例(大约14天可用):http://ge.tt/api/1/files/9eheDrP1/0/blob?download
如果上面的文件不可用,或者您不愿意下载,下面是一个密码:http://pastie.org/8906708
https://stackoverflow.com/questions/22283852
复制相似问题