httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Johnson <...@indietorrent.org>
Subject Re: [users@httpd] moving from mod_php to mod_fcgid : rewrite problem
Date Wed, 13 Feb 2013 16:48:57 GMT


On 2/12/2013 3:19 PM, Riccardo Cohen wrote:
> Hi Ben
> I tried without the dot : RewriteRule ^en/(.*) index.php/en/$1 but it
> gave also an error 404.

It would be helpful to know what, exactly, appears in Apache's access
log (and/or error log, if you can manage to find that, too) in each of
these test cases.

> These are all my tests : (available at
> http://www.perspectives-musicales.org/test1/a/b/c etc.)
> 
> RewriteRule ^test1/(.*) ./test.php/$1
> # = error 404

I hit this URL and from what I can tell, the 404 response header is
coming from PHP, not Apache. The output is "No input file specified."
This doesn't look like a "stock" Apache 404 response. Did you build
logic into test.php that emits a 404 response header and this message
when some parameter is absent from the URL?

> RewriteRule ^test2/(.*) ./test.php?$1
> # = parameters are in query_string instead of path_info

Why is this a problem?

It should be stated that mod_php and mod_fcgid populate these values in
different ways. From what I understand, PATH_INFO is less reliable and
less well-implemented than QUERY_STRING. Fundamentally, this is why you
are observing different behavior/values here after moving from mod_php
to mod_fcgid.

> RewriteRule ^test3/(.*) ./test.php?/$1
> # = parameters are in query_string instead of path_info

Same as above.

> RewriteRule ^test4/(.*) http://www.perspectives-musicales.org/test.php/$1
> # = redirection 302

I don't see a 302 response for this one. I see the same 404 and message
as above. Maybe you changed something after sending this message.

> RewriteRule ^test5/(.*) test.php/$1
> # = error 404
> 
> RewriteRule ^test6/(.*) /test.php/$1
> # = error 404

Same as the others with 404 responses.

> 
> I could not find the apache error log, so I'll ask my hosting support
> team and get back to you
> 
> Thanks for your help.

You're welcome. I'll wait to hear back before offering additional
information.

-Ben

> 
> 
> On 12/02/13 19:40, Ben Johnson wrote:
>>
>>
>> On 2/12/2013 10:59 AM, Riccardo Cohen wrote:
>>> Thanks Ben, here are the answers :
>>>
>>>> 1.) Where have you defined the rewrite rule? In a .htaccess file?
>>>
>>> in .htaccess
>>>
>>>> 2.) Have you defined a RewriteBase? If so, what is it?
>>>
>>> no change with or without
>>>
>>>> 3.) Have you reviewed Apache's access log at all?
>>>
>>> I'll have a look now
>>>
>>>> 4.) Have you increased RewriteLogLevel to, say, 4, to see exactly what
>>>> the mod_rewrite engine is doing?
>>>
>>> I'll try that. Is it possible to set it in .htacces or must I change
>>> global apache configuration (I only have access to my .htaccess in this
>>> hosting).
>>
>> Unfortunately, RewriteLogLevel can be set in the "server config" and
>> "virtual host" contexts only. (You can make this type of determination
>> in the future by visiting the manual page and looking for the "context"
>> value:
>> http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriteloglevel .)
>>
>> This is one of many reasons for which hosting on a VPS over which you
>> have complete control is beneficial.
>>
>> In any case, we'll have to proceed without access to the rewrite log.
>>
>> Is there a specific reason for which you're using "./index.php" in the
>> right-hand side of the rule? I'm referring to the period ("."), in
>> particular. This may well be the source of the problem. It could be that
>> mod_php interprets that relative path (./index.php) "correctly", whereas
>> mod_fcgid does not.
>>
>> Try this:
>>
>> RewriteRule ^en/(.*) index.php/en/$1
>>
>> -Ben
>>
>>
>>
>>> Thanks
>>>
>>> On 12/02/13 14:53, Ben Johnson wrote:
>>>>
>>>>
>>>> On 2/12/2013 2:16 AM, Riccardo Cohen wrote:
>>>>> Hello
>>>>> I received some clues from this list members, thanks for that. But
>>>>> unfortunately my problem is not solved.
>>>>>
>>>>> It's not that I want others to focus on me, but I'm quite sure that
>>>>> there is a real problem (if not why would it work perfectly on mod_php
>>>>> ?), I could not find any solution googling about it (even with the
>>>>> help
>>>>> of the host technical team), and I would like a confirmation that 1)
>>>>> it's not an error from my understanding, and 2) there is no workaround
>>>>> for it.
>>>>
>>>> I doubt it is a problem with the software. mod_rewrite has been put
>>>> through the paces over the years and I'd be shocked if a bug were
>>>> uncovered given your rule's relative simplicity.
>>>>
>>>> Before digesting your post in its entirety, I have a couple of
>>>> questions
>>>> first.
>>>>
>>>> 1.) Where have you defined the rewrite rule? In a .htaccess file?
>>>>
>>>> 2.) Have you defined a RewriteBase? If so, what is it?
>>>>
>>>> 3.) Have you reviewed Apache's access log at all?
>>>>
>>>> 4.) Have you increased RewriteLogLevel to, say, 4, to see exactly what
>>>> the mod_rewrite engine is doing?
>>>>
>>>> -Ben
>>>>
>>>>
>>>>
>>>>> So I'll be very pleased to here from some qualified developer before
I
>>>>> spend 2 days to modify and retest all my application.
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> On 07/02/13 11:17, Riccardo Cohen wrote:
>>>>>> Sorry to insist but I'm really blocked and I really need help.
>>>>>> Here is a small summary for those who don't want to read all :
>>>>>>
>>>>>> I want to make a rewrite from :
>>>>>>
>>>>>> http://www.perspectives-musicales.org/en/all-albums
>>>>>> to
>>>>>> http://www.perspectives-musicales.org/index.php/en/all-albums
>>>>>>
>>>>>> my rewrite rule is
>>>>>>
>>>>>> RewriteRule ^en/(.*) ./index.php/en/$1
>>>>>>
>>>>>> This works when apache is runnnig with mod_php, but not when running
>>>>>> mod_fcgid (php as cgi). In cgi mode I have a 404 error.
>>>>>>
>>>>>> The Apache version is 2.2.23 and mod_fcgid is version 2.3.7 with
>>>>>> configuration flag cgi.fix_pathinfo=1
>>>>>>
>>>>>> Thanks for your help.
>>>>>>
>>>>>>
>>>>>> On 05/02/13 21:32, Riccardo Cohen wrote:
>>>>>>> Hello
>>>>>>> I'm new to apache mailing list, sorry if I'm not 100% clear,
and
>>>>>>> sorry
>>>>>>> for this long description.
>>>>>>>
>>>>>>> I have developped a website with php/mysql :
>>>>>>> http://www.perspectives-musicales.org and placed it on a good
>>>>>>> hosting
>>>>>>> service (web4all.fr).
>>>>>>> To improve search engine rank I decided to set all urls to
>>>>>>> /index.php/... and rewrite them to avoid having index.php in
url
>>>>>>> (sort
>>>>>>> of MVC technique combined with SEO...)
>>>>>>>
>>>>>>> Example : the catalog is at url :
>>>>>>> http://www.perspectives-musicales.org/en/all-albums
>>>>>>> This should be transparantly mapped to
>>>>>>> http://www.perspectives-musicales.org/index.php/en/all-albums
>>>>>>> thanks to
>>>>>>> the rewrite rule :
>>>>>>>
>>>>>>> RewriteRule ^en/(.*) ./index.php/en/$1
>>>>>>>
>>>>>>> My application uses then $_SERVER["PATH_INFO"] (and not
>>>>>>> $_SERVER["QUERY_STRING"]) to retreive url information. This worked
>>>>>>> perfectly until last month, because web4all.fr changed the whole
>>>>>>> system
>>>>>>> and separated apache from php, using fast cgi instead of mod_php.
>>>>>>>
>>>>>>> The system is supposed to be more reliable and more efficient
like
>>>>>>> this,
>>>>>>> and apparently is. But the rewrite rule does not work anymore.
So I
>>>>>>> investigated and made some test :
>>>>>>>
>>>>>>> I have a small test.php that displays the path_info and
>>>>>>> query_string.
>>>>>>> You can presently test it here :
>>>>>>>
>>>>>>> http://perspectives-musicales.org/test1/a/b/c
>>>>>>> http://perspectives-musicales.org/test2/a/b/c
>>>>>>> http://perspectives-musicales.org/test3/a/b/c
>>>>>>> http://perspectives-musicales.org/test4/a/b/c
>>>>>>>
>>>>>>> and I set the following rules :
>>>>>>>
>>>>>>> RewriteRule ^test1/(.*) ./test.php/$1
>>>>>>> RewriteRule ^test2/(.*) ./test.php?$1
>>>>>>> RewriteRule ^test3/(.*) ./test.php?/$1
>>>>>>> RewriteRule ^test4/(.*)
>>>>>>> http://www.perspectives-musicales.org/test.php/$1
>>>>>>>
>>>>>>> None of these 4 rewrite rules are convenient. Here is why :
>>>>>>>
>>>>>>> - test1 : the system anwsers 404 "No input file specified". I
think
>>>>>>> (not
>>>>>>> sure) that Apache beleives that test.php is a folder, and cannot
>>>>>>> find it
>>>>>>> so answers 404
>>>>>>>
>>>>>>> - test2 : the rewrite rule works, but of course the url
>>>>>>> information is
>>>>>>> no more in path_info, it is in query_string as shown in the page
>>>>>>> content
>>>>>>>
>>>>>>> - test3 : same as test2
>>>>>>>
>>>>>>> - test4 : almost good, I can have the url info in path_info,
but
>>>>>>> apache
>>>>>>> begins first with a 302 redirection and then changes the url
to
>>>>>>> http://www.perspectives-musicales.org/test.php/a/b/c, which
>>>>>>> looses all
>>>>>>> search engine efficiency (and also eventual POST variables if
any).
>>>>>>>
>>>>>>> My host tried several searches on forums including this one,
and
>>>>>>> could
>>>>>>> not find any answer. It seems to be an apache bug, but not sure,
I
>>>>>>> have
>>>>>>> no bug number to give anyway. If it is a bug, it is demontrated
by
>>>>>>> test1
>>>>>>> I think.
>>>>>>>
>>>>>>> So here is my question : Is there any way to make this rewrite
rule
>>>>>>> work
>>>>>>> in fastcgi mode, and what is the syntax for it, to keep info
in
>>>>>>> path_info without 302 redirection. The Apache version is 2.2.23
 and
>>>>>>> mod_fcgid is version 2.3.7 with configuration flag
>>>>>>> cgi.fix_pathinfo=1
>>>>>>>
>>>>>>> If there is a way, thanks for your help I'd be glad to test it.
>>>>>>> If no
>>>>>>> could you explain why and how to solve it. As workaround we used
>>>>>>> test4
>>>>>>> syntax in the whole site, to make it work, but it is bad for
search
>>>>>>> engine, and creates problem in backoffice (because certain
>>>>>>> backoffice
>>>>>>> functions use POST variables)
>>>>>>>
>>>>>>> I know I can change my code to use query_string everywhere
>>>>>>> instead of
>>>>>>> path_info, but if I can avoid changing and testing all my
>>>>>>> websites it
>>>>>>> would be really great
>>>>>>>
>>>>>>> Thanks a lot for your anwser.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message