How would i create a custom dynamic url in codeigniter - .htaccess

I hate the codeigniter custom urls where it's: domain.com/controller/action/username
How can I have it like a normal website like: domain.com/username
Please give me a suggestion.

You try this in routes.php
$route['(:any)'] = "controller/action/$1";
Here is the routing documentation : routing

Please refer http://ellislab.com/codeigniter/user-guide/general/routing.html. You can do this by URL routing

Related

Codeigniter Controller class login form : 404 page not found

Im trying to combine several tutorials about Codeigniter and bootstrap and understand per codes so i can integrate it in my project. What i am trying to do right now is create a login form using the two framework.
And i setup my View according to the turotial included in Codeigniter 'user_guide/tutorial/static_pages.html' which my landing page is named as 'home.php' is inside the folder 'pages' and header.php, and footer.php is inside the 'templates' folder. I created also a controller: Page.php.
I also use .htaccess to hide 'index.php'. Now i follow this tutorial how to create a login page:
http://learnjquerybootstrap.blogspot.com/2015/01/login-session-using-codeigniter-and-bootstrap.html?m=1
-the only difference is this since i use htaccess:
<?php echo form_open(clogin/index); ?>
But when I try to submit the page i receive a: 404 page not found.
My navbar links are working fine. I understand that the codeigniter works like this:
http://localhost/myfolder/index.php/class/function/
so when i submit my form the url that show up is:
http://localhost/myfolder/clogin/index
and gives me: 404 page not found.
Question:
What is wrong with it?
is there something wrong with the tutorial that i am using? i check other tutorials and the controller structure is just the same, like on this link:
http://www.kodingmadesimple.com/2014/08/how-to-create-login-form-codeigniter-mysql-twitter-bootstrap.html
do i need to include clogin.php in route.php?
or is it about the htaccess? my
uri_protocol
is configured as
'REQUEST_URI'
in config.php. i tried other options but still the same.
Don't need include to route.
I recommented ready auth library.
If you use DevTools in your browser maybe "Network" tab of devtools can help you to why you get 404 error.
i already firgured it out.The mistake was in the route.php, since i tried to combine two examples.. i realized that the wildcard route that i included from the Codeigniter user guide will not work with the Clogin.php.
Since it was set as
$route['(:any)']='pages/view/$1';
So the url works as
http://localhost/myfolder/pages/view/clogin
instead of
http://localhost/myfolder/clogin.
I removed it and now it is working.

Liferay Friendly URL struts action not fired

Please help me to implement Friendly URL
My source URL
http://localhost:8080/web/guest/myshop? p_p_id=225_INSTANCE_08MX& p_p_lifecycle=0 &p_p_state=normal& p_p_mode=view& p_p_col_id=column-1&
p_p_col_count=1 &_225_INSTANCE_08MX_struts_action=%2Fproduct%2Fview_product
&_225_INSTANCE_08MX_redirect=http%3A%2F%2Flocalhost%3A8080%2Fweb%2Fguest%2Fprodu­ct%3Fp_p_id%3D25_INSTANCE_08MX%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mo­de%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1%26_225_INSTANCE_08MX_%252F­%3D&_225_INSTANCE_08MX_productId=25414
Please can some one help me to write route file.
Thanks
Tania

Prestashop module page url rewrite in htaccess

i have created a controller in prestashop module. my url is like this http://www.prestashop.com/module/homepageadvertise/brands/
i want my url should be like this
http://www.prestashop.com/brands/
How can i achieve it by changing the htaccess?
yau can change in BO > prefences > SEO & URL > just add new , in page you chose module, in Rewritten URL type brands
and save

Routes in Codeigniter

I want to have a clean URL in CodeIgniter based application for User's Profile Information.
Please Take a look at URL formats below.
Actual URL : http://www.mydomain.com/index.php/users/profile/user1
I'm expecting users to have Personal URL's like
http://www.mydomain.com/user1
http://www.mydomain.com/user2
http://www.mydomain.com/user3
URL http://www.mydomain.com/user1 should process http://www.mydomain.com/index.php/users/profile/user1 in background execution.
I will be removing index.php from URL using Route library.
Thanks in advance for any sort of help.
Have a look at https://www.codeigniter.com/user_guide/general/routing.html.
$route['user(:num)'] = "users/profile/user/$1";
If you mean you want /anyusername to route to the users controller, you would have to put:
$route['(:any)'] = "users/profile/$1";
At the bottom of routes.php and every non user-URL above it. Otherwise every URL would be routed there, obviously. You will need to implement some mechanism in the users-controller to throw 404-errors, since you are routing all requests not catched in the routing rules above.
IN config/routes.php
add this line
$route['user(:num)'] = "users/profile/$1";

Kohana - Facebook app URL

I'm developing my first facebook app on kohana 2.3.x at the moment and I noticed that a usual app url should look like this:
http://apps.facebook.com/{my_app}/{controller}/{method}
But in my app it shows the real url.
http://mydomain.com/{controller}/{method}
Any idea how to fix that in Kohana?
Thanks in advance!
Try changing this in application/config/config.php:
$config['site_domain'] = 'apps.facebook.com/my_app/';

Resources