1

I was having trouble deploying my site. My Angular partials were receiving a 404 error but my index.php template was loading fine. This was my .htaccess:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

I found the solution here: Codeigniter - no input file specified

It was to add a ? after index.php.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

I have a basic understanding of .htaccess but I can seem to find an explanation for this.

Thanks.

Community
  • 1
  • 1
Neurion
  • 379
  • 6
  • 15
  • I think it's something related to FastCGI, I have encountered this issue multiple times before so I started adding the question mark by default to all my deployments as it doesn't affect other environments. – ahmad May 21 '16 at 17:29

1 Answers1

1

In the first case, without ?, the parameters of your request are held in PATH_INFO.

In the second case, with ?, this is the most common QUERY STRING variable.

They are both part of $_SERVER super global, but they are set by HTTP server. It all depends on the Apache/Nginx/Lighttpd/whatever configuration. PATH_INFO is not always set: it's not safge to rely on this variable.

But when route is passed in the URL without ?, it can also be read with REQUEST_URI. Software (framework in your case) needs to be able to read it.

It is important to have the same development and production environments. Since you cannot change this configuration in shared hosting environment (whereas you can do what you want on a virtual or dedicated server), you should check the production configuration first, then adapt your local configuration so that your code can easily be deployed.

Arcesilas
  • 1,388
  • 11
  • 24