问题原文
原帖链接 · MadsHaupt · CC BY-SA 3.0
I try to make a regular expression in a .htaccess file, that matches only an empty string.
I have tried many things, but it seems like it’s impossible. For example, I tried ^$, but it's looking for "" that will always exist in a string.
So I seek answers to it all possible.
If possible, I would like to hear how to extend such a regular expression together.
Here is the content of my .htaccess file:
RewriteEngine On
RewriteRule ^$ https://stald-mariendal.dk/index_tekst [R=302,L]
RewriteRule ^guestbook.html$ https://stald-mariendal.dk/gaestebog [R=301,L,NE]
RewriteRule ^sites/guestbook.html$ https://stald-mariendal.dk/gaestebog [R=301,L,NE]
RewriteRule ^guestbook$ https://stald-mariendal.dk/gaestebog [R=301,L,NE]
RewriteRule ^(\w+).html$ https://stald-mariendal.dk/$1 [R=301,L,NE]
RewriteRule ^sites/(\w+).html$ https://stald-mariendal.dk/$1 [R=301,L,NE]
RewriteCond %{HTTPS} on
RewriteRule ^(\w+)$ ?site=$1.html [L]
RewriteCond %{HTTPS}| off
RewriteRule (.*) https://stald-mariendal.dk%{REQUEST_URI} [R=301,L,NE]
社区高分解答
原帖链接 · Rounin · CC BY-SA 3.0
I wasn't convinced this would work, but I've tested it and it does seem to.
Quite simply:
^.{0}$
Where:
^ is the start of the match
. is any character (except newline)
{0} is precisely zero times
$ is the end of the match
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
