Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8895543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:48:28+00:00 2026-06-14T23:48:28+00:00

I am testing G-WAN server and I’d like using rewrite rules. With apache the

  • 0

I am testing G-WAN server and I’d like using rewrite rules.

With apache the rule is :

RewriteRule ^(.+)-(.+)-(.+)-1.jpg$ imagesproduitnew/$3/$2.jpg [L]

I am trying to do it by handlers JPG, but I have lot of difficulties.

Has anybody already done something like that ?


My handlers is called url_wr.c in the path /0.0.0.0_80/#0.0.0.0/handlers
Here is the script

int init(char *argv[], int argc);

int main(int argc, char *argv[])
{
   const long state = (long)argv[0];
   if(state == HDL_AFTER_READ)
   {
      xbuf_t *read_xbuf = (xbuf_t*)get_env(argv, READ_XBUF);
      xbuf_replfrto(read_xbuf, read_xbuf->ptr, read_xbuf->ptr + 16, "/blog", "/?blog");
   }
   return 255; // execute next connection step
}

int clean(char *argv[], int argc);

In gwan.log, it is not writen loaded url_wr.c
If I put printf in each function, it doesn’t work.
The servlet bloc.c works well.

I also tried tu put the code in handlers/main.c and in the root of gwan directory.

I have only a error.log file for the site which says just error404 without any details of the handlers.

Thanks by advance for your support

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:48:29+00:00Added an answer on June 14, 2026 at 11:48 pm

    You must use a G-WAN connection handler, either to use:

    • a plain-rewrite: one example is given at the end of the developers page,

    OR,

    • a regex library (libc provides regex calls) if you target a more general rewrite scheme. Here is an example in C and the explanations are there, courtesy of “Regular Expressions in C” from the “Linux Gazette”.

    This could also be made rom a servlet, but then you would have to trigger a redirection (unless the resource was explicitely placed into a cache). If this is acceptable, then v3.10+ will let you do it in C#, PHP, Python, etc.


    UPDATE following the code published in the question:

    Your init() call is empty so main() is never called. You should do this instead:

    // ----------------------------------------------------------------------------
    // init() will initialize your data structures, load your files, etc.
    // ----------------------------------------------------------------------------
    // init() should return -1 if failure (to allocate memory for example)
    int init(int argc, char *argv[])
    {
       // define which handler states we want to be notified in main():
       // enum HANDLER_ACT { 
       //  HDL_INIT = 0, 
       //  HDL_AFTER_ACCEPT, // just after accept (only client IP address setup)
       //  HDL_AFTER_READ,   // each time a read was done until HTTP request OK
       //  HDL_BEFORE_PARSE, // HTTP verb/URI validated but HTTP headers are not 
       //  HDL_AFTER_PARSE,  // HTTP headers validated, ready to build reply
       //  HDL_BEFORE_WRITE, // after a reply was built, but before it is sent
       //  HDL_HTTP_ERRORS,  // when G-WAN is going to reply with an HTTP error
       //  HDL_CLEANUP };
       //
       u32 *states = (u32*)get_env(argv, US_HANDLER_STATES);
       *states = 1 << HDL_AFTER_READ; // we assume "GET /hello" sent in one shot
       puts("init()");
       return 0;
    }
    

    Also, make sure that connection handlers are named main.c. In contrast, content handlers carry the name of the targeted file extension (gif.c, html.c, etc).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Testing.BSMain, Text: Start Page I would like to substring the value above and returning
For testing I'm using the H2 database . For production it's MySQL . I
//Testing numbers for primality #include <iostream> #include <cmath> using namespace std; int main() {
When testing my app using Instruments -> Activity Monitor, I'm seeing a difference in
When testing scipy using the nose package using scipy.test() , the test fails under
I wan't to use Sql Server 2008 as production environment with provider System.Data.SqlClient and
I am searching a low cost WAN network simulation software for testing my website
For testing purposes I need strings such as: test\x00string I would like to loop
When testing my Tridion content delivery web service using a web browser, I can
For testing purposes I would like to disable flash player so it doesn't display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.