maddig
Goto Top

Rewrite auf einen Unterordner mit NGINX

Guten Morgen,

ich habe ein kleines Problem.

Und zwar will ich wenn ich www.domain.de aufrufe, ein Rewrite einrichten dass dann sofort www.domain.de/cms daraus macht.
Grund ist, dass ich den root-Pfad nicht verschieben will, weil in ihm noch Ordner sind die ich brauche.

Als Webserver dient NGINX.


rewrite ^(.*) http://domain.de/cms$1 permanent;

Das habe ich schon probiert, nur dann schreibt er beim aufrufen ca. 30 mal /cms dahinter und der Brwoser gibt aus das ich zu oft von der Website weitergeleitet wurde..

Ich hoffe ihr könnt mir helfen.

MFG

Content-Key: 314575

Url: https://administrator.de/contentid/314575

Printed on: April 25, 2024 at 10:04 o'clock

Member: Lochkartenstanzer
Lochkartenstanzer Sep 07, 2016 at 06:09:45 (UTC)
Goto Top
Moin,

Du hast eine klassische rekursionsschleife gebaut. Bevor Du den rewrite machst, mußt Du natürlich prüfen, ob Du überhaupt umleiten mußt.

lks
Mitglied: 129813
129813 Sep 07, 2016 updated at 06:14:59 (UTC)
Goto Top
You are rewriting all paths, including the redirected one, which results in a loop.
rewrite ^/?$ http://www.domain.de/cms permanent
Regards
Member: maddig
maddig Sep 07, 2016 at 06:22:27 (UTC)
Goto Top
Thanks highload,

wenn i try your solution and restart nginx i get this error:

Reloading nginx configuration (via systemctl): nginx.serviceJob for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
Mitglied: 129813
Solution 129813 Sep 07, 2016 at 06:24:43 (UTC)
Goto Top
Or this
if ($request_uri !~ "^/cms"){  
  rewrite ^(.*)$ http://www.domain.de/cms$1 permanent
}
Member: maddig
maddig Sep 07, 2016 at 06:45:21 (UTC)
Goto Top
perfect now it works ! thank you
Member: Lochkartenstanzer
Lochkartenstanzer Sep 07, 2016 updated at 07:16:51 (UTC)
Goto Top
Moin,

You schouldn't give always the direct solution, rather give hints. At least, the TOs should have a chance to learn by reading manuals. face-smile

BTW: Do you prefer replies in german for learnig german or in english for easy reading?

lks
Mitglied: 129813
129813 Sep 07, 2016 updated at 07:42:56 (UTC)
Goto Top
Zitat von @Lochkartenstanzer:
You schouldn't give always the direct solution, rather give hints.
Is this "The Millionaire Quiz Board" face-big-smile
At least, the TOs should have a chance to learn by reading manuals. face-smile
Thats's true but we cannot force him to. It will fall him on his foot, early enough face-wink

BTW: Do you prefer replies in german for learnig german or in english for easy reading?
The first face-smile With reading i get a feeling and a visual experience for the words. Will try to write some answers in german in the near future if i feel myself confident.
Member: Lochkartenstanzer
Lochkartenstanzer Sep 07, 2016 at 07:56:56 (UTC)
Goto Top
Zitat von @129813:

Zitat von @Lochkartenstanzer:
You schouldn't give always the direct solution, rather give hints.
Is this "The Millionaire Quiz Board" face-big-smile
At least, the TOs should have a chance to learn by reading manuals. face-smile
Thats's true but we cannot force him to. It will fall him on his foot, early enough face-wink

Naja, Wenn die Leute alles auf denm Präsentierteller bekommen, erzieht man sie dazu, daß sie die Lösungen nur aus Internet-Foren ergooglen und erfragen, statt einfach mal auf die manpage zu schauen. Da hätte sich das if-statement geradezu aufgedrängt. Und wenn jemand keine manpages lesen kann, wird er sehr oft blaue Zehen bekommen.

BTW: Do you prefer replies in german for learnig german or in english for easy reading?
The first face-smile With reading i get a feeling and a visual experience for the words. Will try to write some answers in german in the near future if i feel myself confident.

o.k. Werde also in ZUkunft deutsch antworten. Aber trau Dich ruhig. Wir helfen auch gerne bei Sprachproblemen. N'es pas? face-smile


lks
Mitglied: 129813
129813 Sep 07, 2016 at 08:45:43 (UTC)
Goto Top
erzieht man sie dazu, daß sie die Lösungen nur aus Internet-Foren ergooglen und erfragen
Well, i restrict myself to raise my kids face-wink.
Und wenn jemand keine manpages lesen kann, wird er sehr oft blaue Zehen bekommen.
In the next job interview, i will ask the candidate to take off his shoes face-wink then everything's clear.