yhk1038 / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

Feature request: Parse .htaccess files and extract mod_rewrite information #84

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be great if mongoose (optionally) supported mod_rewrite-rules.

mod_rewrite is one of the most commonly used and
you'll-notice-it's-missing-as-your-page-doesn't-work-anymore Apache
extensions. This would enhance the program's usefulness for website testing
a lot.

Original issue reported on code.google.com by phillip....@googlemail.com on 28 Aug 2009 at 6:57

GoogleCodeExporter commented 9 years ago
It sounds tempting, but when I start thinking about this, the implementation 
seems 
complex to me. Main thing is the regexp syntax - the last thing I want is to 
reimplement it. Also I don't want to depend on any third party regex library.

Maybe reusing mod_rewrite DLL is a way to go? Then, Mongoose needs to 
understand 
Apache module API. I'll take a look in what is involved in this. If it could be 
done 
very easy (which I doubt), then it is worth trying, otherwise it'll be a 
deviation 
from the design goals.

Original comment by valenok on 31 Aug 2009 at 3:45

GoogleCodeExporter commented 9 years ago
Maybe it is worth coming up with our own .htaccess file format?
That would allow to create rewrite rules based on error codes as well on URI 
regular 
expressions, attach different web root directories (-aliases option), etc?

Original comment by valenok on 31 Aug 2009 at 4:08

GoogleCodeExporter commented 9 years ago
Oh, I thought you already used one [misinterpreted your match_regex function's 
name
:-)]. At least for *ix, mingw and cygwin: POSIX libc has builtin support for 
extended
regular expressions, see regex(3).

I already looked at apache's mod_rewrite.c/so. As far as I understand it, it 
can't be
used without depending on other apache libraries.

Another option was to introduce a (compile-time?) plugin system for that. This 
would
allow code contribution without messing around [I actually filed this bug 
because I
didn't know how to implement the feature by myself in a clean fashion :-)] and 
still
keep the core application clean and slim.

Original comment by phillip....@googlemail.com on 31 Aug 2009 at 5:23

GoogleCodeExporter commented 9 years ago
I've implemented simple rewrite functionality with -url_rewrite_patterns 
option, check out the latest code.
I think it is suitable for the basic needs, marking this as fixed.

Original comment by valenok on 29 Jan 2012 at 7:34

GoogleCodeExporter commented 9 years ago
Hello valenok,  
I'm buidling a REST api on top of mongoose with php.  I woudl like to use the 
Slim Framworkm that need the rewrite feature.  When I use your modification, 
./bin/mongoose -r  ./http -d yes -C cgi,php -I <absolute path to php-cgi>

I go your modification and when I try to use it php doesn't get parsed (I see 
the text version of the file when I request file.php instead of the interpreted 
output), even when I'm not using the new -w switch....

- can I use your modification with php?
- I'd like to specify something similar to what is recommended in the slim 
interface.  I'm not sure of the syntax of your new switch...  something like 
-w"^(.*)$ index.php [QSA,L]" maybe?

Slim recommend the following .htaccess rewrite directives:

<--- begin snipet -->
RewriteEngine On

# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
<-- end snipet -->

thanks,

philippe

Original comment by ateliers...@gmail.com on 3 Feb 2012 at 8:21

GoogleCodeExporter commented 9 years ago
Note that in the head version the syntax for -C has been changed.
Philippe, if you describe in words how the redirection should work, I can 
suggest how Mongoose should be started.

Original comment by valenok on 5 Feb 2012 at 10:31