url routing in codeigniter like wordpress clean url - codeigniter

How to code or achieve this url like wordpress
for example
http://www.example.com/product/view/my-product-sample
is there way to have this url ? any tips tutorial example thank you guys :)

Well, this is already a valid URL without any alteration, calling the controller product, method view with the argument my-product-sample.
However, I think you are looking for routing.
Example:
$route['product/view/(:any)'] = 'products/view_product/$1';
This route is saying: If user requests
product/view/(something)
give them
products/view_product/(something)
As usual, see the user guide for more information.

Related

Codeigniter - Htaccess : How to change a controller name

This is my first question here, so Hi all! ^^
I created a website with codeigniter framework and I have inserted a module for multilanguage. The url looks like this:
http://www.mywebsite.com/en/controller/function
The problem came when the client wanted to send a newsletter to all its customers in another language, but do not want to send the url with the controler with the name in english, because the newsletter is for spanish users.So:
URL is going to be send:
http://www.mywebsite.com/es/thecontroller
URL the client wants to be send ("elcontrolador" is "thecontroler" in spanish):
http://www.mywebsite.com/es/elcontrolador
I dont want to create another controler named "elcontorlador" only to show the same page as "thecontroler", because we don't want duplicate content for SEO purposes.
So, i want via .htaccess, a rule that when i type
http://www.mywebsite.com/es/elcontrolador
in the URL, mywebpage shows the info of
http://www.mywebsite.com/es/thecontroler
but with the URL
http://www.mywebsite.com/es/elcontrolador
(the controler "elcontrolador" doesnt exist).
So, is there any way to do this with the htaccess? I've tried it myself but I failed miserably i come here desperate, because I run out of time to deliver it and can not find a viable solution. I'll have to create the extra controller?
Need help D:
Maybe you can use the route config file instead to achieve this ?
$route['es/elcontrolador'] = 'es/thecontroler';
I don't know how you handle your multilangage, but you've got the idea.

Wrong url in magento paging

I have a problem regarding paging of the custom module. When i click on the next page the it take the url as localhost/magento/fme-support/index/index/url/BC/?p=1, but this url doesn't work properly, the correct URL is localhost/magento/fme-support/category/BC/?p=1.
Please suggest me how and i change this url.
Thanks.
Try making url rewrites off
If it doesn't work there is some issue with your extension you have installed
Check for redirect in your extension
The "index" in the URL means you are calling the index controller of the module.
Magento module URLs work like this
http://magento_installation.com/(storeview)/moduleMame/controllerName/functionName/

Codeigniter URL routing

After searching a lot around, I decided to post this matter here.
I am working with codeigniter ( latest release). I need to have the URLs of my site working like below.
[username] / [controller] / [action] / [parameters]
as you can see the username is leading on the URL rest follows as normal. I need to fetch the username and get some data for the site so that that site could be customized according to his settings.
I tried to achieve this with .htaccess but had no luck. Then I checked with routing on code igniter, but I am not sure whether it's the right solid solution for me. can someone give me any leading on this. is this possible ?
Thanks
I would advise to use the routing option from Codeigniter.
http://codeigniter.com/user_guide/general/routing.html
$route['(:any)/user/viewprofile/(:num)'] = controllername/functionname/$2";
This way you can build classes and functions in an nicely ordered way.And keep it in codeigniter.
$route['(:any)/controller'] = 'controller/users/$1';
This will pass the dynamic username to the controller

Codeigniter redirection

Hi I created a codeigniter project but when I click on a link to one of my functions, example add user, I get redirected to the main page of my local host XAMPP installation instead of being taken to the correct application url. What can be the problem? Thanks
Have you set the base URL in the CI configuration? file projectname/application/config/config.php? This might be the problem... I guess your project isn't on the webroot, but your base URL is missing the /projectname/ part.
$config['base_url'] = 'http://example.com/projectname/';
How do you create the link (can you show us the code)? If you are not using the URLHelper take a look at urlHelper.
I am just guessing, but maybe you are missing the Controller name (you have to load the UrlHelper), e.g.:
Link to the controllers method
or (see Jordan Arsenault's comment below on the usage of the site_url call for better performance):
<?= anchor('/name_of_the_controller/method_to_invoke', 'Link to the controllers method'); ?>
I hope this helps.

ActionLink pointing to route not affected by current route

I have am problem because I have a menu where the links always should point to MyController/MyAction, but the site has other routes that go to the same action, but with more parameters.
Will give me the route but if I am currently on the same action and controller, but with more params these are included in the url as well.
Eg. if I am on the page:
http://localhost/MyWebsite/organizations/p001/departments/vest/employees/chn/MyController/MyAction
the url generated will be the same as above and not:
http://localhost/MyWebsite/MyController/MyAction
as i would like. Any suggestions?
Ahh found out that I could use RouteLink instead...

Resources