Mobile app version of vmapp.org
Login or Join
Carla537

: How can I get a regular expression to only match an empty string? (In a .htaccess file) I try to make a regular expression in a .htaccess file, that matches only an empty string. I have

@Carla537

Posted in: #Apache #Htaccess #ModRewrite #Redirects #RegularExpression

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 ^$ stald-mariendal.dk/index_tekst [R=302,L]
RewriteRule ^guestbook.html$ stald-mariendal.dk/gaestebog [R=301,L,NE]
RewriteRule ^sites/guestbook.html$ stald-mariendal.dk/gaestebog [R=301,L,NE]
RewriteRule ^guestbook$ stald-mariendal.dk/gaestebog [R=301,L,NE]
RewriteRule ^(w+).html$ stald-mariendal.dk/ [R=301,L,NE]
RewriteRule ^sites/(w+).html$ stald-mariendal.dk/ [R=301,L,NE]
RewriteCond %{HTTPS} on
RewriteRule ^(w+)$ ?site=.html [L]
RewriteCond %{HTTPS}| off
RewriteRule (.*) stald-mariendal.dk%{REQUEST_URI} [R=301,L,NE]

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Carla537

1 Comments

Sorted by latest first Latest Oldest Best

 

@Sherry384

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme