fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

8.7K
active users

#mod_rewrite

0 posts0 participants0 posts today
pikesley_ebooks<p>Foster kittens fighting with <a href="https://mastodon.me.uk/tags/mod_rewrite" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>mod_rewrite</span></a>.</p>
maexchen1<p><span class="h-card" translate="no"><a href="https://chaos.social/@twinkelicious" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>twinkelicious</span></a></span> </p><p>Ich habe immer versucht vieles ohne irgendein Plugin zu machen.</p><p>Jetzt kommt es auf deinen Webserver an.</p><p>Ist es ein Apache, kannst Du das Redirecting and Remapping mit <a href="https://nrw.social/tags/mod_rewrite" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>mod_rewrite</span></a> erledigen.</p><p>Da kannst Du hinterlegen was passiert wenn irgendwas aufgerufen wird.</p><p>Bei Dir, dass Bild wird angeklickt und die Webseite wird aufgerufen.</p><p>Das schöne daran ist, es ist eine Text Datei.<br>Da gibt es viele Möglichkeite das zu Automatisieren.</p><p><a href="https://httpd.apache.org/docs/2.4/rewrite/remapping.html" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">httpd.apache.org/docs/2.4/rewr</span><span class="invisible">ite/remapping.html</span></a></p>
My name is Gordo<p>Can someone please explain to me why an Apache mod_rewrite rule would apply in Chrome, but not in Firefox? Basically, I'm taking the requested subdomain, e.g. [something].mywebsite.com, and using that string to 301 redirect to mywebsite.com/[something]. Works perfectly in Chrome, but hasn't worked in Firefox in a while (first version worked in both, but I had to reimplement it after a WordPress update overwrote it) and I have no idea why that should be a thing. We basically have zero Firefox users attempting to use the subdomain aside from myself, so it doesn't *really* matter, but I just want to understand (and avoid an unnecessary customer service email in the event that a Firefox user scans the QR code and erroneously ends up at the homepage; yes, the subdomain was a mistake. But the QR codes are out there by the thousands, so it's too late for me now lol).</p><p>I should say that the majority of my mod_rewrite experience was probably a decade or so ago, so I'm definitely pretty rusty.</p><p>The rule:</p><p>RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.(mywebsite\.com)$ [NC]<br>RewriteRule ^ http://%2/%1%{REQUEST_URI} [L,R=301,NE]</p><p><a href="https://hachyderm.io/tags/apache" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>apache</span></a> <a href="https://hachyderm.io/tags/mod_rewrite" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>mod_rewrite</span></a> <a href="https://hachyderm.io/tags/server" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>server</span></a></p>
Beat Bolli :kt_be:<p>So this should get rid of the bots:</p><p> # Deny bots<br> RewriteCond %{HTTP_USER_AGENT} "[Bb]ot/|meta-externalagent"<br> RewriteRule .* - [G]</p><p><a href="https://swiss.social/tags/apache" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>apache</span></a> <a href="https://swiss.social/tags/mod_rewrite" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>mod_rewrite</span></a></p>
🪑Dr Rockstar ♫Long post
🪑Dr Rockstar ♫<p>This is where I am w/ the github repo <span class="h-card" translate="no"><a href="https://social.vivaldi.net/@zombiewarrior" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>zombiewarrior</span></a></span> </p><p>It's really close to being "right", so to speak. </p><p>compare that to e.g. <br><a href="http://statecollegeguitarlessons.com/adb/index.php" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">http://</span><span class="ellipsis">statecollegeguitarlessons.com/</span><span class="invisible">adb/index.php</span></a></p><p>Note: my server is <a href="https://social.vivaldi.net/tags/LiteSpeed" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>LiteSpeed</span></a> and i don'[t mess w/ it. But, that should not have the /public/ in the URL. If you've ever worked w/ <a href="https://social.vivaldi.net/tags/laravel" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>laravel</span></a> it's like the ./index.php of the proj dir there. where there's ./index.php "reditrecting" to ./public/index.php <br>but you need to mod the <a href="https://social.vivaldi.net/tags/NGINX" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>NGINX</span></a> server {} location {} stuff for the... mod_rewrite type stuff. <br>i.e. the URL should be .com/giterator/ , accomplished in nginx w/ "@alias"<br>(sans the ./public part). you see the same thing either way. pet peeves. </p><p>EDIT: ALSO! CORRECTION -do NOT see the same! ARGGH! w/out that <a href="https://social.vivaldi.net/tags/mod_rewrite" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>mod_rewrite</span></a> bit <a href="https://social.vivaldi.net/tags/htaccess" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>htaccess</span></a> whatever!~ the <a href="https://social.vivaldi.net/tags/CSS" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>CSS</span></a> <a href="https://social.vivaldi.net/tags/asset" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>asset</span></a> paths mess up as well. Prob explains the missing SVG (masthead.php) forgot about that. oh well. hey. gimme a damn break! brain damage!<br>SEE "new" version here, ( i can fix that path thing. i forget the quick path top of my head momentarily. i prefer to be correct instead, anyway!) <br>this is NOT correct! <a href="http://statecollegeguitarlessons.com/giterator/public/index.php" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">http://</span><span class="ellipsis">statecollegeguitarlessons.com/</span><span class="invisible">giterator/public/index.php</span></a></p><p>first time w/ the <a href="https://social.vivaldi.net/tags/namespace" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>namespace</span></a> <a href="https://social.vivaldi.net/tags/php8" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>php8</span></a> <a href="https://social.vivaldi.net/tags/composer" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>composer</span></a> <a href="https://social.vivaldi.net/tags/autoloader" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>autoloader</span></a> <a href="https://social.vivaldi.net/tags/PSR4" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>PSR4</span></a> <a href="https://social.vivaldi.net/tags/MVC" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>MVC</span></a> <a href="https://social.vivaldi.net/tags/refactoring" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>refactoring</span></a>. </p><p>i must admit, it was more challenging that i expected. </p><p>but yea. feel free to hop in there at any time, and help me polish that old turd already!<br>Sheesh!</p>
Kevin Karhan :verified:<p><span class="h-card" translate="no"><a href="https://possum.city/@mook" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>mook</span></a></span> <span class="h-card" translate="no"><a href="https://mastodon.social/@MastodonEngineering" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>MastodonEngineering</span></a></span> <em>EXACTLY THIS</em> is why I think a <em>"<a href="https://infosec.space/tags/Webhoster" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Webhoster</span></a>-only"</em> functional <a href="https://infosec.space/tags/ActivityPub" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>ActivityPub</span></a> server is kinda important.</p><ul><li>And if <a href="https://infosec.space/tags/Mastodon" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Mastodon</span></a> was that, I could understand them saying <em>"<a href="https://infosec.space/tags/canfix" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>canfix</span></a> &amp; <a href="https://infosec.space/tags/wontfix" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>wontfix</span></a>"</em> for all the valid reasons (tho I'm shure <a href="https://infosec.space/tags/PHP" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>PHP</span></a> devs fluent in <a href="https://infosec.space/tags/mod_security" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>mod_security</span></a> &amp; <a href="https://infosec.space/tags/mod_rewrite" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>mod_rewrite</span></a> would likely disagree!)...</li></ul><p>And for what Mastodon does, it feels quite overengineered and overcomplex, but then again I'm used to <a href="https://infosec.space/tags/MkDocs" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>MkDocs</span></a> and other, <em>"<a href="https://infosec.space/tags/offline" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>offline</span></a>-<a href="https://infosec.space/tags/CMS" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>CMS</span></a>|es"</em> that do just work and are kinda essential for stuff on <span class="h-card" translate="no"><a href="https://mastodon.social/@torproject" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>torproject</span></a></span> / <a href="https://infosec.space/tags/Tor" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Tor</span></a> because noone there uses <a href="https://infosec.space/tags/JavaScript" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>JavaScript</span></a> and enabling <a href="https://infosec.space/tags/JS" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>JS</span></a> is discouraged by <a href="https://infosec.space/tags/TorBrowser" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>TorBrowser</span></a> for <em>all the right reasons</em>...</p><p>I should take a closer look at <a href="https://infosec.space/tags/streams" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>streams</span></a> once I have time for that...</p>
Donncha<p>Earlier this month I noticed that a particular bot that likes to visit my website, “MJ12bot/v1.4.8” seems to be particularly attracted to the “reply to comment” links generated by my blog. Those are links that bots see, but we see the “Reply” button that uses JavaScript to reply to a comment.</p><p>To be honest, it’s pretty annoying to see a bot constantly fetching those URLs from my website. Earlier this month, it was on a roll and grabbing several dozen at a time. While my server can handle the traffic without any issues, who wants a bot trampling over their server?</p><p>I decided to stop them in two ways:</p><p>Redirect them back to the post in a mod_rewrite rule.Block them in robots.txt and hopefully the bots will go away.</p><p>Coming up with a mod_rewrite rule <a href="https://mastodon.ie/@donncha/109834002975042301" rel="nofollow noopener" target="_blank">was surprisingly hard</a>, but after mentioning this on Mastodon I received a reply from <a href="https://toot.re/@JosKleverWebSupport" rel="nofollow noopener" target="_blank">Jos Klever</a> who figured out I needed the QSD flag. So, to spare you the hassle of researching it, here are the mod_rewrite rules that worked for me. It causes a 301 permanent redirect to the anchor tag of the comment.</p><p>RewriteCond %{QUERY_STRING} replytocom=(.*)$RewriteRule ^(.*)/ $1/#comment-%1 [NE,QSD,L,R=301]</p><p>Blocking requests like this in the robots.txt is much simpler. WordPress can generate the robots.txt file for you using the <a href="https://developer.wordpress.org/reference/hooks/robots_txt/" rel="nofollow noopener" target="_blank">robots_txt filter</a>. Add the following to a mu-plugin PHP script.</p><p>function disallow_replycom_urls( $output, $public ) { $output .= 'Disallow: ?replytocom'; return $output;}add_filter( 'robots_txt', 'disallow_replycom_urls', 10, 2 );</p><p>I haven’t received many comments on my posts lately. However, I stumbled upon some interesting posts by clicking the RANDOM link above, which I decided to examine as part of my research. During my search, I delved deep into the blogosphere of the past, almost like being an archaeologist, because some links were no longer available, and I had to search for them on archive.org. I was also pleasantly surprised to find that a link to a GIF from 2005 was still alive!</p><p><a rel="nofollow noopener" class="u-tag u-category" href="https://odd.blog/tag/mod_rewrite/" target="_blank">#mod_rewrite</a> <a rel="nofollow noopener" class="u-tag u-category" href="https://odd.blog/tag/robots-txt/" target="_blank">#robots-txt</a> <a rel="nofollow noopener" class="u-tag u-category" href="https://odd.blog/tag/wordpress/" target="_blank">#wordpress</a></p><p><a href="https://odd.blog/2023/02/27/redirecting-replytocom-so-bots-go-home/" rel="nofollow noopener" target="_blank">https://odd.blog/2023/02/27/redirecting-replytocom-so-bots-go-home/</a></p>