简体   繁体   English

使用Codeigniter路由和.htaccess URL重写

[英]Using Codeigniter Routing and .htaccess URL rewriting

I wanted to understand Codeigniter URL Routing and .htaccess URL Rewriting. 我想了解Codeigniter URL路由和.htaccess URL重写。 Are both same? 都一样吗

Basically, I want to hide my ID which is passed to the controller. 基本上,我想隐藏传递给控制器​​的ID。 Do I want to understand how can I use any of them to do so? 我是否想了解如何使用它们中的任何一个?

Also is it possible that I can just show my domain and the folder name and hide another part of URL 也有可能我只显示我的域和文件夹名称并隐藏URL的另一部分

Eg. 例如。

www.example.com/distributor/tenant/info/1

www.example.com/distributor

So can I hide my controller and id using .htaccess 所以我可以使用.htaccess隐藏我的控制器和ID

My Current .htaccess looks like this 我当前的.htaccess看起来像这样

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /bizcloudds/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]

</IfModule>

Can this same thing be done with Codeigniter Routes? Codeigniter路由可以做同样的事情吗?

I saw something like this on codeigniter's documentation on Routes : 我看到像这样的笨的文档上的Routes

$route['blog/joe'] = 'blogs/users/34';

But I don't understand how will I get 34 ie ID of the record in my routes files? 但是我不明白如何在路由文件中获取记录的ID(即34

I have very little knowledge of .htaccess and Codeigniter Routes, So please explain. 我对.htaccess和Codeigniter路由知之甚少,所以请解释一下。

By using post method you can find solution for your question. 通过使用post方法,您可以找到问题的解决方案。 For example 例如

<form action="page_url" method="POST">
<input name="id" value="16" type="hidden">
<input type="submit" value="Show Details">
</form>

Hope you understand. 希望你能理解。 If you need more guidance on this, I'm happy to help you out. 如果您需要更多指导,我们很乐意为您提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM