Как подружить .htaccess файл для популярных CMS с Nginx

Начну с небольшого вступления: зачем вообще нужен .htaccess файл? .htaccess — это конфигурационный файл, который использует веб‑сервер Apache для задания специфических настроек для каждой отдельной папки сайта. Благодаря ему можно:

https://habr.com/ru/articles/1013982/

#nginx #nginx_module #mod_rewrite #htaccess

Как подружить .htaccess файл для популярных CMS с Nginx

Начну с небольшого вступления: зачем вообще нужен .htaccess файл? .htaccess — это конфигурационный файл, который использует веб‑сервер Apache для задания специфических настроек для каждой отдельной...

Хабр
Foster kittens fighting with #mod_rewrite.
I was fighting with #mod_rewrite.

Apache #mod_rewrite rule to stop bots from scraping your content:

# Deny bots
RewriteCond %{HTTP_USER_AGENT} "[Bb]ot/|meta-externalagent|Chrome/1[^34]|Chrome[02-9]"
RewriteRule .* - [G]

The Chrome terms catch obsolete version numbers that the bots seem to use.

#nobots

Sunday fun with #mod_rewrite
Foster kittens fighting with #mod_rewrite.

@twinkelicious

Ich habe immer versucht vieles ohne irgendein Plugin zu machen.

Jetzt kommt es auf deinen Webserver an.

Ist es ein Apache, kannst Du das Redirecting and Remapping mit #mod_rewrite erledigen.

Da kannst Du hinterlegen was passiert wenn irgendwas aufgerufen wird.

Bei Dir, dass Bild wird angeklickt und die Webseite wird aufgerufen.

Das schöne daran ist, es ist eine Text Datei.
Da gibt es viele Möglichkeite das zu Automatisieren.

https://httpd.apache.org/docs/2.4/rewrite/remapping.html

Redirecting and Remapping with mod_rewrite - Apache HTTP Server Version 2.4

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).

I should say that the majority of my mod_rewrite experience was probably a decade or so ago, so I'm definitely pretty rusty.

The rule:

RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.(mywebsite\.com)$ [NC]
RewriteRule ^ http://%2/%1%{REQUEST_URI} [L,R=301,NE]

#apache #mod_rewrite #server

So this should get rid of the bots:

# Deny bots
RewriteCond %{HTTP_USER_AGENT} "[Bb]ot/|meta-externalagent"
RewriteRule .* - [G]

#apache #mod_rewrite

@zombiewarrior RE: Nginx / Litespeed #Mod_Rewrite stuff?

Having it as a subdirectory of the #wordpress installation of course is problematic (if file paths aren't correct etc).

it was just quick to show you. i can make a subdomain, but i'm losing the hosting anyway. so...

#FML