#FollowerPower Who can tell me Apache2 mod_rewrite config in a .htaccess to pass a environment variable to a CGI script (running with suexec).
#FollowerPower Who can tell me Apache2 mod_rewrite config in a .htaccess to pass a environment variable to a CGI script (running with suexec).
Как подружить .htaccess файл для популярных CMS с Nginx
Начну с небольшого вступления: зачем вообще нужен .htaccess файл? .htaccess — это конфигурационный файл, который использует веб‑сервер Apache для задания специфических настроек для каждой отдельной папки сайта. Благодаря ему можно:
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.
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.
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]
So this should get rid of the bots:
# Deny bots
RewriteCond %{HTTP_USER_AGENT} "[Bb]ot/|meta-externalagent"
RewriteRule .* - [G]