Skip to content

Using rewrite for OctoberCMS #79

Open

Description

@marianielias

Hi,
I'm trying to adapt the rewrite rules of OctoberCMS to httpd.conf.
Now everything is working ok with this rules:

#example of directory that doesn't need to use rewrite.
location match "/themes/(.*)/assets/(.*)" {
request no rewrite
}

#index.php is the entry point of the application and runs the php fastcgi.
location match "index.php" {
fastcgi socket "/run/php-fpm.sock"
}

#all others locations rewrite to /index.php
location match "(.*)" {
request rewrite "/index.php$REQUEST_URI"
}

The problem is that when rewriting to index.php in this manner the links are formatted in the same way as the rewrite, is there a way apart from "request strip" that I can use to change the $REQUEST_URI so the fastcgi socket gets the value with the "/index.php" striped ?
Or even better: a way to keep the original $REQUEST_URI ?

Cheers.

Activity

  1. leonstafford commented on Nov 7, 2018

    @leonstafford

    Did you have any advancement in this?

    I'm currently looking into doing the same for WordPress and would think the capture index (%1, %2, etc) would be usable to craft your own URL rewrites without the index.php:

         block [return code [uri]]
                 Close the connection and send an error page.  If the optional
                 return code is not specified, httpd(8) denies access with a `403
                 Forbidden' response.  The optional uri argument can be used with
                 return codes in the 3xx range to send a `Location:' header for
                 redirection to a specified URI.
    
                 It is possible to rewrite the request to redirect it to a
                 different external location.  The uri may contain predefined
                 macros that will be expanded at runtime:
    
                       $DOCUMENT_URI  The request path.
                       $QUERY_STRING  The URL encoded query string of the request.
                       $REMOTE_ADDR   The IP address of the connected client.
                       $REMOTE_PORT   The TCP source port of the connected client.
                       $REMOTE_USER   The remote user for HTTP authentication.
                       $REQUEST_URI   The request path and optional query string.
                       $SERVER_ADDR   The configured IP address of the server.
                       $SERVER_PORT   The configured TCP port of the server.
                       $SERVER_NAME   The name of the server.
                       $HTTP_HOST     The host from the HTTP Host header.
                       %n             The capture index n of a string that was
                                      captured by the enclosing location match
                                      option.
    

    That's from the block docs in man httpd.conf, but rewrite says to use the same macros

  2. marianielias commented on Nov 7, 2018

    @marianielias
    Author

    @leonstafford
    No advancement. I'm currently hosting my sites in a hosting provider so I'm not following the subject. Maybe the functionality that I'm asking for is just not implemented in httpd.
    Cheers.

  3. leonstafford commented on Nov 7, 2018

    @leonstafford
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions