在cpanel中使用动态URI段重定向URL [英] Redirecting URL with dynamic URI segment in cpanel
问题描述
<a href="www.mysite.com/index.php?information/adminpanel/<?php echo $id;?>" name="approve"
id="approve" ">Approve >></a>
当我重定向到这个网址时,它显示了正确的网址地址,但给了网页找不到的错误。我是cpanel的新手。请告诉我是否有其他方式可以通过此ID或如何路由页面在cPanel中使用uri段。
When I am redirecting to this url it shows correct id in url but gives page not found error. I am new to cpanel. Please tell me is there any other way I can pass this id or how to route page in cpanel with uri segment.
推荐答案
大多数情况下,您在URL中缺少一部分内容,除非您更改了 .htaccess
文件。
Most probably you are missing a part in URL unless you have changed the routing in .htaccess
file somehow.
正确的URL最有可能是(如果你没有改变任何东西)
The right URL should most probably be (if you didn't change anything)
www.mysite.com/index.php?route=information/adminpanel&some_id=<?php echo $id ?>
请注意,应该发送控制器/操作
部分作为变量 route
下的查询字符串的一部分,并且ID变量必须是查询字符串的一部分以及下的变量变量然后从 $获得_GET ['younameit']
在您的控制器中。
Note that the controller/action
part should be sent as a part of query string under the variable route
and that the ID variable has to be a part of query string as well under you name it variable that is then obtained from $_GET['younameit']
in your controller.
OpenCart中的路由可以通过SEO URL完成,如
The routing in OpenCart is done either via SEO URLs like
www.mysite.com/category-slug/sub-category-slug/product-slug
甚至
or even
www.mysite.com/product-slug
当它们被 mod_rewrite
规则翻译时into
while these are being translated by mod_rewrite
rule into
www.mysite.com/index.php?_route_=<SEO_URL_PART>
或非SEO网址,您需要指定控制器
or by non-SEO URLs where You need to specify the controller
www.mysite.com/index.php?route=common/home
调用 CommonHomeController
的默认 index()
动作,或者甚至通过指定要在
where the default index()
action of CommonHomeController
is invoked or even by specifying the concrete action to be invoked as in
www.mysite.com/index.php?route=checkout/cart/add
其中 add()
code> CheckoutCartController 被调用。因为这样调用一个URL,比如
where the add()
action of CheckoutCartController
is invoked. Because of this calling an URL like
www.mysite.com/index.php?route=information/adminpanel/123
会导致尝试调用动作 123()
在 InformationAdminpanelController
中,这可能不存在。如果您拨打网址,则不需要这样做。
would lead to trying to invoke the action 123()
within the InformationAdminpanelController
which most probably does not exist. Instead of this if you call URL
www.mysite.com/index.php?route=information/adminpanel&some_id=123
它将是 index()
动作当你可以获得像这样的 some_id
值时:
it will be the index()
action invoked while you can obtain the some_id
value like this:
if (!empty($this->request->get['some_id'])) {
$some_id = $this->request->get['some_id'];
} else {
$some_id = 0;
}
if ($some_id) {
// ...
}
再次说明 - 上述所有内容都是默认的OpenCart路由行为,并且也适用于您的安装,除非您更改了 mod_rewrite
在 .htaccess
文件中定义的规则。
Again - all described above is the default OpenCart routing behavior and will apply for your installation as well unless you have changed the mod_rewrite
rules defined in .htaccess
file.
这篇关于在cpanel中使用动态URI段重定向URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!