home.social

#modrewrite — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #modrewrite, aggregated by home.social.

fetched live
  1. Managed to get this setup working on shared webhosting 🥳

    matthias-andrasch.eu -> SvelteKit
    matthias-andrasch.eu/blog -> WordPress
    matthias-andrasch.eu/* -> SvelteKit

    Folders:
    web/matthias-andrasch.eu/
    -- blog/
    -- sveltekit/

    Advantage of two folders: Easier to deploy, blog/ won't get deleted by accident on SvelteKit deployment (otherwise robust exclude roles needed if these two would be in one folder).

    SvelteKit is deployed via FTP Deploy GitHub action (adapter-static)

    Thanks to @s2b for the hint!

    gist.github.com/mandrasch/46a0

    #sveltekit #wordpress #apache #modrewrite

  2. Okay, this SEEMS to work. The database is just the start addresses for lots of /8, /16, /24 or /32 ranges (depending on the size of the requested block - e.g. a /22 range gets written as the start address for four /24s) taken from okean.com/antispam/iptables/rc and mapped to "BLOCKED" and then built into a database file with `httxt2dbm`.

    ```
    # Extract IP parts
    RewriteCond %{REMOTE_ADDR} ^((([0-9]+)\.[0-9]+)\.[0-9]+)\.[0-9]+$
    RewriteRule . - [E=subnet8:%3.0.0.0,E=subnet16:%2.0.0,E=subnet24:%1.0,E=subnet32:%0]

    # Tarpit provided by a Mastodon user - mastodon.social/@pcarrier/1124
    # We don't have access to mod_cspnonce yet, so fudge a random-ish value
    RewriteCond ${greatfirewall:%{ENV:subnet8}} =BANNED [OR]
    RewriteCond ${greatfirewall:%{ENV:subnet16}} =BANNED [OR]
    RewriteCond ${greatfirewall:%{ENV:subnet24}} =BANNED [OR]
    RewriteCond ${greatfirewall:%{ENV:subnet32}} =BANNED
    RewriteRule . srv.us/tarpit?nonce=%{REMOTE_PORT}%{TIME} [L,E=donotlog:1,R=301]
    ```

    (`donotlog` is used later to avoid logging, because when they hit so hard and so often then I don't need that bloat in my server logs!)
    Not yet worked out why it only seemed to work within <VirtualHost> blocks.

    #Apache #Apache2 #ModRewrite #spam #AbusiveBots

  3. So, apparently "FallbackResource" is the cool and trendy new(ish) way to do "rewrite all missing URLs to this file, which will generate an error page".

    Except… there's no way to write it to a _single_ file if you've got subdirectories? Even with "/index.php", it seems to look for that file _within_ the subdirectory 😐

    #Apache #SysAdminProblems #WebmasterProblems #ModRewrite

  4. des experts du #ModRewrite d'#Apache dans le coin ? Petite question : je passe un nom de ville dans une URL sous la forme /ville/NOM DE LA VILLE/.
    ceci fonctionne : /ville/Paris/
    mais pas ça : /ville/Les%20Ulis/
    j'obtiens une belle erreur 403 : "You don't have permission to access this resource."

    ma règle est pourtant simple :
    RewriteRule "^/ville/(.*)/$" index.php?ville=$1 [L]

    Une idée de comment je peux corriger ça, j'ai beau tourner le problème dans tous les sens, je ne trouve pas de solution.

    Merci :)

  5. To webadmins out there: remember to test your .htaccess files. One easy way to check is on this online website, if its contents isn't sensitive:

    htaccess.madewithlove.com

    To test the regular expressions included in a mod_rewrite, there's this website that even has a stepping debugger:

    regex101.com

    #webadmin #sysadmin #htaccess #modrewrite

  6. It's surprisingly hard to redirect from URL/?replycom=XXXX to URL/#XXXX

    The following rule redirect to URL/ but miss out the anchor tag. The hash character gets encoded unless you add [NE] but then "?" doesn't remove the query parameter. I bet I'm missing something pretty obvious.

    RewriteCond %{QUERY_STRING} replytocom=(.*)$
    RewriteRule ^(.*)/ $1/? [L,R=301]

    #WordPress #ModRewrite