demenvil / phpdesktop

Automatically exported from code.google.com/p/phpdesktop
1 stars 0 forks source link

Url rewrite patterns in settings.json - equivalent of apache's mod_rewrite #81

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Mongoose web server has an option named "url_rewrite_patterns". We should allow 
for adding url rewrite patterns to settings.json. Instructions should be 
provided with examples on how to make work existing Apache patterns with 
Mongoose. For example:

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

What would be the equivalent in Mongoose?

Some frameworks do not make it easy to disaable pretty urls and url rewriting. 
So we should definitely support it.

Original issue reported on code.google.com by czarek.t...@gmail.com on 10 Feb 2014 at 3:33

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've had a look at the Mongoose docs over at 
http://cesanta.com/docs/Options.shtml, and it looks like mongoose takes a 
parameter "-url_rewrites" that allows you to specify any URL rewrite options. 
However, there does not seem to be any method yet to implement these in the 
settings.json.

It's pretty essential to get url rewriting implemented, as previously stated, 
many PHP frameworks just won't work without this.

Original comment by toady.b...@gmail.com on 11 Jun 2014 at 3:07

GoogleCodeExporter commented 9 years ago
<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Mongoose equivalent:

'mongoose -url_rewrites **=www/index.php'

Unfortunately this would lose the "$1" part of the RewriteRule, as Mongoose's 
rewrite options are not as powerful as Apache's mod_rewrite. So if we're using 
Mongoose, people who want to use Frameworks that require this kind of thing 
might be out of luck.

Original comment by toady.b...@gmail.com on 11 Jun 2014 at 3:17

GoogleCodeExporter commented 9 years ago
@comment #4 toady.bomb
We can always modify Mongoose sources to add support for the $1 parameter in 
url rewrites. We already use a custom version of Mongoose that was modified to 
provide several fixes and new features.

Original comment by czarek.t...@gmail.com on 11 Jun 2014 at 8:23

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
See Issue 137 and the __fix_mongoose_env_variables() php function that fixes 
issues with Mongoose environment variables when using urls like 
"index.php/company/5".

Original comment by czarek.t...@gmail.com on 27 Oct 2014 at 8:03

GoogleCodeExporter commented 9 years ago
Added support for pretty urls with basic url rewriting for 404 errors in 
revision 190fbae92d05.

Example usage is in the pretty-urls.php script:
https://code.google.com/p/phpdesktop/source/browse/phpdesktop-chrome/www/pretty-
urls.php

See the ["web_server"]["404_handler"] option on the Settings wiki page:
https://code.google.com/p/phpdesktop/wiki/Settings#web_server

PHP Desktop Chrome 31.8 was not yet released, but you can download the main 
executable from the alternative download site. Direct link:
https://www.dropbox.com/sh/3ihzy40v62em613/AABqIRiSNXVqjZra_-nG2kGia/phpdesktop-
chrome-31.8.exe?dl=0

Original comment by czarek.t...@gmail.com on 27 Oct 2014 at 11:46

GoogleCodeExporter commented 9 years ago
Reopening issue. Current implementation of pretty urls has problems with POST 
requests. Issue was reported on Forum 
(https://groups.google.com/d/msg/phpdesktop/NLZnCUqveUQ/20SmPXH4XVQJ). This is 
due to 302 redirect being made when pretty url is accessed. It needs to be 
investigated if a 302 redirect can be made using the original POST method. 
According to this 
(http://stackoverflow.com/questions/8138137/http-post-request-receives-a-302-sho
uld-the-redirect-request-be-a-get) Chrome may have problems with that.

Original comment by czarek.t...@gmail.com on 28 Oct 2014 at 8:05

GoogleCodeExporter commented 9 years ago
307 Temporary Redirect should be made to preserve POST data. See for reference:
 * https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection
 * http://stackoverflow.com/questions/2068418/whats-the-difference-between-a-302-and-a-307-redirect

Original comment by czarek.t...@gmail.com on 28 Oct 2014 at 8:14

GoogleCodeExporter commented 9 years ago
Using 307 redirect fixes the issue. Unfortunately using redirect to access 
pretty urls during POST requests has a side effect when reloading page. After a 
post request is made, F5 reload causes request method to be changed to GET. It 
also affects Back/Forward navigation.

Current implementation needs to be rethinked. An alternative implementation 
without the need for a redirect when accessing pretty urls would require 
changes in mongoose.c > convert_uri_to_file_name(), somewhere around the url 
rewriting code.

Original comment by czarek.t...@gmail.com on 28 Oct 2014 at 9:44

GoogleCodeExporter commented 9 years ago
Fixed issues with POST requests when accessing pretty urls. New implementation 
does not depend on redirects anymore.

Fixed Mongoose environment variables: REQUEST_URI, PHP_SELF and others. It is 
no more required to use __fix_mongoose_env_variables() php func.

Updated pretty-urls.php example.

Changes in revision 39c81a7b2b24.

phpdesktop 31.8 executables was updated on dropbox.

Original comment by czarek.t...@gmail.com on 29 Oct 2014 at 10:41

GoogleCodeExporter commented 9 years ago
Fixed C memory issues in revision 2600acd0a30e. Executable on dropbox was 
updated.

Original comment by czarek.t...@gmail.com on 29 Oct 2014 at 11:36