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
Related
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
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
I want to redirect my all old url to new url.
My few old URLs are
domain.com/
domain.com/submit
domain.com/get/soft-name
domain.com/most-downloaded
etc, etc,
Now i want to redirect my all url to
domain.com/en
domain.com/en/submit
domain.com/en/get/soft-name
domain.com/en/most-downloaded
I am using CodeIgniter. Please Suggest me some code for route.php
thanks in advance
If you want to handle this in your routing, you could just do this:
$route['(:any)'] = "en/$1";
How can I rewrite the following urls in CodeIgniter
localhost/users/show_profile/john
to
localhost/john
Thanks
you can achieve dynamic URL using CodeIgniter Routes.
Assuming
localhost/users/show_profile/john
We're looking at:
localhost/controller/method/variable
we can use the following route:
$route['([a-zA-z_]+)'] = "users/show_profile/$1";
You can access the variable by calling $this->uri->segment(1); inside show_profile() function.
IMPORTANT: keep the $route['([a-zA-z_]+)'] at the end of the routes.php file, to make sure it's not overriding any other routes.
If you only need to do it for a defined set of URLs, update /config/routes.php
If you need it to be dynamic then you should extend the CodeIgniter Router Library.
http://codeigniter.com/user_guide/general/creating_libraries.html (look for Extending Native Libraries)
In config/routes.php add $route['(:any)'] = "users/show_profile/$1";
More info on routes here