$route['404_override'] = 'my404';
$route['(:any)'] = 'home/templateOne/$1';
While using this route 404 error, it is not working and
showing an error like this:
This page isn’t working example. In redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
Related
When i re hit the vue-router url its return 404 page not found.
I running it on laravel 5.8. in web.php file
I tried some of these but they don't work
Route::get('/{capture_all?}', 'HomeController#index')->where('capture_all', '[\/\w\.-]');
Route::get('/{vue_capture?}', 'HomeController#index')->where('vue_capture', '[\/\w\.-]');
Route::get('/{any}', 'HomeController#index')->where('any', '[\/\w\.-]');
the page will refreshed
Consider a fallback route:
Route::fallback('HomeController#index');
Any unknown route will be passed to this fallback route. Any known routes (like to your APIs) will remain untouched.
I am a beginner in codeigniter 3.1.2.
While I am running localhost//ci it shows 404 page not found error. ci is my folder name.
What should I do?
May be you gets 404 error because of Controller.
Defining a Default Controller
CodeIgniter can be told to load a default controller when a URI is not present, as will be the case when only your site root URL is requested. To specify a default controller, open your application/config/routes.php file and set this variable:
$route['default_controller'] = 'blog';
Where ‘blog’ is the name of the controller class you want used. If you now load your main index.php file without specifying any URI segments you’ll see your “Hello World” message by default.
For more information, please refer to the “Reserved Routes” section of the URI Routing documentation.
or may be there .htaccess problem
check link for more https://www.sitepoint.com/community/t/404-page-not-found-the-page-you-requested-was-not-found-codeigniter-project/223800
I defined the default_controller as "Home" in routes.php. When example.com is written as url, the page works. It also works when example.com/home is written as url. Could I show 404 error page when example.com/home is entered as url?
The other question is I have two functions in Home.php in controller folder. When I call a function such as contact, the url is seen like example.com/home/contact. Could I show the url such as example.com/contact instead of .com/home/contact?
This can all be done, with Routes.
Your first question;
"Could I show 404 error page when example.com/home is entered as url?"
$route['home'] = '404';
This would show a 404 page whenever someone tries to visit /home. If you visit / it would show the default controller.
The second question:
"Could I show the url such as example.com/contact instead of .com/home/contact?"
Again, this is pretty easy with Routes.
$route['contact'] = 'home/contact';
Anyone who visits /contact would see the home/contact method.
Hope this helps.
I am trying to set up a 301 redirect for the "Default-route" in codeigniter.
I know I can set up a route to another page, but I need it to redirect instead.
Does anyone know how?
Yes you can set a controller function on error page where we will call a view
$route['404_override'] = 'errors/index_404';
errors is controller and index_404 is action(function) where we calling our custom view page
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