简体   繁体   中英

Using Codeigniter Routing and .htaccess URL rewriting

I wanted to understand Codeigniter URL Routing and .htaccess URL Rewriting. Are both same?

Basically, I want to hide my ID which is passed to the controller. 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

Eg.

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

www.example.com/distributor

So can I hide my controller and id using .htaccess

My Current .htaccess looks like this

<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?

I saw something like this on codeigniter's documentation on 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?

I have very little knowledge of .htaccess and Codeigniter Routes, So please explain.

By using post method you can find solution for your question. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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