2
votes

How are you?

Summary: I'm trying to move my website from localhost to amazon-ec2 and almost any route brings "The requested URL example.com/xxx/yyy/ was not found on this server.

Context:

  • Using codeigniter structure in public_html, applications and system.
  • Web language in the URI. Example: localhost/public_html/es/main.
  • For testing, one page (register) it's routed differently: localhost/public_html/admin/register.
  • The page works from localhost.

Issue: I uploaded the page to my EC2, and when I try to access, almost every page shows the 404 error. Just register page works, but only if I call it via example.com/index.php/admin/register (example.com/admin/register carries the same 404 error).

Any advice or idea to explore would be very welcome!! Thanks!!

PS: In case it helps, I'm sharing my current routes.php code.

$route['default_controller'] = "main";
$route['404_override'] = '';
$route['^(en|es)/(.+)$'] = "$2";
$route['^(en|es)$'] = $route['default_controller']; 
2
the trivial point to start looking from would be to find the string that hits the routing function and see how it is different from the routes-regex you have defined; don't you need to single out pattern start and end?Grigorash Vasilij

2 Answers

4
votes

The issue was in the httpd.conf, where "AllowOverride" for public_html (where I had the .htacces file) was set at "None".

I just had to change it to All.

Thanks AchrafSoltani and Grigorash for the try, very appreciated!

3
votes

Issue: I uploaded the page to my EC2, and when I try to access, almost every page shows the 404 error. Just register page works, but only if I call it via example.com/index.php/admin/register (example.com/admin/register carries the same 404 error).

That means that either the .htaccess is missing not correctly set. By default, code igniter relies on index.php to process all the requests, but since it looks ugly on the URL you should add a .htaccess with the correct parameters to remove it from the url, then open config.php from system/application/config directory and replace :

$config['index_page'] = “index.php” 

to

$config['index_page'] = “”