I have a URL in my Codeigniter
http://localhost:64743/index.php/mybox?name=John
I want it to look something like this
http://localhost:64743/index.php/mybox/name/John
is it posiible? how does custom URL works in CodeIgniter?
$route['mybox/(:any)'] = "mybox/index";
user above mention code in routes.php of config folder and you will get query string value by $this->uri->segment(3); and $this->uri->seggment(4);
for further assistance, please check
https://ellislab.com/codeigniter/user-guide/general/routing.html
Related
I am rewriting my yii2 website urls.In my config file i added
'<category_name>-<controller>-<category_id>'=>'<controller>/index'
and in the url i just passed the parameters like
<?=Url::to(['shop/index','category_id'=>1,'category_name'=>'clothes'])?>
And my url comes like
https://example.com/clothes-shop-1
This is what i am getting. But i need something like
https://example.com/clothes-1
for that i just changed the rule like this
'<category_name>-<category_id>'=>'<controller>/index'
But that time rewriting doesn't working.How can i remove the controller name from that url
How does system know, what controller is needed to proceed URL? In first example
'<category_name>-<controller>-<category_id>'=>'<controller>/index'
There is a controller name. In second
'<category_name>-<category_id>'=>'<controller>/index'
No controller name.
So you need to tell it. Try
'<category_name>-<category_id>'=>'shop/index'
I have developed a website with PHP Codeigniter. It consists of many controllers and views. I want to encrypt the URL of the site to hide the controller and function name. Currently, the URL looks like this :
www.sitename.com/controller_name/function_name
I don't want the users to see the controller and function names. Is it possible to do this now because the site is almost complete. Is there any shortcut of doing this? Please Help
You can use codeigniter URI Routing to remove your controller name from URL.
$route['url_name'] = 'controller_name/function_name';
This `www.sitename.com/url_name` will look go to `www.sitename.com/controller_name/function_name`
$route['url_name/(:any)'] = 'controller_name/$1';
This will only change your controller name.. `controller_name` to `url_name`
I have issue with page redirection with codeigniter, I want to redirect from http://mywebsite_domain/index.php/home/show/206 , to http://mywebsite_domain/index.php/ar/home/pages/show/206 . And My controller name "pages" in "home" folder
please help me....
Just you have to write some code in routes.php in application/config/routes.php.
$route['show/(:any)'] = 'ar/home/pages/show/$1';
See more at CodeIgniter - Routing
You can use codeigniter's URI routing.
refer the below link-
http://www.codeigniter.com/userguide2/general/routing.html
In that you can also use Regular Expressions to get generalized URI routing.
routes.php => /application/config/routs.php
hi unable to display my product name and categories in url of codeigniter website
actually muy url is: http://manimukta.com/search/details/738/5/5 like this
i want to make this url to http://manimukta.com/Arts&Artifacts/Silver-Articles/Decoratives/Animal/Horse/738/5/5
can u please help me out
Go to application folder and in your config.php file change the $config['permitted_uri_chars'].
$config['permitted_uri_chars'] = 'a-z 0-9~%.:&_\-,()!$';
You have to use codeigniter routing concept which is helped your question
for ex :
$route['product/(:any)'] = "search/detail";
In your url has product it will look up 'search' controller and 'detail' function
further detail refer below
https://ellislab.com/codeigniter/user-guide/general/routing.html
I am developing web with Codeigniter. I what the url like this:
[site]/[company_name]. The [company_name] is dynamic.
For example: http://www.abc.com/alixa
But the real url is: http://www.abc.com/shop/alixa
Is there anyway can I do with this? with htaccess or route in codeigniter?
Yap you can do it from both .htaccess and routes
here is solution from using routes
$route['(:any)'] = 'shop/$1';
by using this route you will getting problem from other url as if you wants
http://www.abc.com/mysecoundController/myfunction
it will also redirect to shop controller,
For this you have to write more routes
as
$route['(mySecoundController:any)'] = 'mySecoundController/$1';
$route['(:any)'] = 'shop/$1';
here is the link for detail
http://codeigniter.com/user_guide/general/routing.html
You can check this article that include all the information that you need: http://www.web-and-development.com/codeigniter-minimize-url-and-remove-index-php/#removing-first-url-segment