Need to change hmvc routes in CodeIgniter - codeigniter

I have CodeIgniter HMVC application and I want to change route as per requirement.
Now I have website/product/detail/url, and I want to change it with website/url.
Once I set URL from admin side it will redirect to my route.
This is what I have now:
$route['Products'] = "Products/detail/d101productdatatest(this is url)";
And I want in my url like website/url and it will open same page what I have with website/product/detail/url

From the given library:
https://www.codeigniter.com/userguide3/general/routing.html
routes as above:
$route['controller/function'] ='website/Products/detail/d101productdatatest';
But as per your given question:
you cannot manipulate url using routes
you can map same function with different url using routes
you have to use .htaccess to redirect to specific url after hitting the previous given url.
htaccess example:
Redirect /index.html /new/
Redirect /index.html /default.html
Redirect /private/ http://www.example.com/private/
Redirect /img/logo.gif http://www.example.com/images/logo.gif
Hope this answer helps you out !!
cheers

Related

Redirect 301 a single URL using htaccess or routes.php

I am trying to redirect /es/services to /es/servicios but I'm unable to do it, I've tried on .htaccess with
Redirect 301 /es/services mydomain.net/es/servicios
But nothing happens, also wanna say only on /es language so how can I do it?? I'm using laravel 5.5
Thanks!

URL redirection in codeigniter

I need help in url redirection in codeigniter,
I have following url
http://test.com/MyProject/My13d2lnbGlsZGNtcWt0Z2w=
When I click above url, then it should redirect to my function like,
http://test.com/MyProject/api/TestingManagement/getMyUrl/My13d2lnbGlsZGNtcWt0Z2w=
We can do it with CI routes or .htaccess, but how?
Thanks in advance
For Routes you can write following as last rule:
$route['(:any)'] = 'api/TestingManagement/getMyUrl/$1';

Laravel URL without Mod_rewrite

I want to call an function in a controller in a cronjob. This is not working because of mod_rewrite.
What is the correct URL for accessing this function without mod_rewrite?
For example, my url with mod_rewrite is:
http://url.com/public/index.php/cron/time_enabled
How can i call this without mod_rewrite?

Route to admin page in codeigniter

I'm working with Codeigniter and i want to have a URL like this:
admin.domain.com
And then route it to the real controller and function.
It means I don't want to have a URL like this : www.domain.com/admin.
I have one controller for back-end and another for front.
This is my default controller in route file:
$route['default_controller'] = "home";
so how should i do it? with route file or htaccess file or some another way?!

Change URL in address bar but keep on same page

Is it possible to rewrite a url so that the page stays the same and the url itself is chanaged ?
E.G.:
I have a page at www.example.com/sales
I want this url to appear in the address bar as www.example.com/sales_and_repairs
I am NOT trying to redirect a page at www.example.com/sales to ANOTHER page at www.example.com/sales_and_repairs ....There is only ONE page - it is just the URL I am trying to change so that if a person types in www.example.com/sales, they will go to that page but the URL in the Address bar will change to show as www.example.com/sales_and_repairs
Is this possible with rewrite rules ? Anytjhing I have looked up appears to suggest that you have to be redirecting to a second page - but that is not what I want to do - I just want to change the actual URL.
Any advice please ??
If you want to redirect www.example.com/sales_and_repairs to www.example.com/sales permanently you can do it with an .htaccess file.
First of all, you'll have to enable mod_rewrite in apache.
Then add the following to your .htaccess file :
Options +FollowSymlinks
RewriteEngine on
Rewriterule ^http://www\.example\.com/sales_and_repairs$ http://www\.example\.com/sales [R=301,NC,L]
This method allow you to have only one file behind the two urls.
However if you want to modify the url after a user's action, you can do it with the answer given by Sparda above.
Seems you can achieve this with javascript :
location.hash = 'newurl';
But this will add an anchor to the url.
Some earlier features of html5 can do this but are not really supported yet :
history.pushState(data, 'title', 'newurl');

Resources