Pretty URLs rewrite sometimes with “?” sometimes without

I hope someone can answer “why” this is the case:

There are times I can use:

Read More
...
RewriteRule ^(.*)$ index.php/$1 [L]

and then there are times where the above doesn’t work and I must use:

...
RewriteRule ^(.*)$ index.php?/$1 [L]

the main difference being the addition of ? … I typically see this happen on different system setups, fastcgi vs module vs cgi, but haven’t done enough setups to see the pattern.

I am guessing that it is related to how the apache/setup parses path/path_info data. Any thoughts are welcomed, ideally I’d like to have a solid explanation of why this is and when it occurs.

On the same thread … Sometimes Apache does not output PATH_INFO environment var which might be the root cause of this, but I wonder why that is.

Related posts

Leave a Reply

1 comment

  1. The ? is the marker of the beginning of the query string.

    So basically your first rule rewrite a URL "x" to a file "x" in the directory index.php, the second rewrite a URL "x" to the index.php file with parameter "x". [(BTW I don’t know how to retrieve a variable with no name in the file, usually you use ?var=value&var2=value2 etc…)