With and without a slash

What would I do this rule so that you can access it without a slash?

RewriteRule ^members/([^/]+)$ members.php?id=$1 [L]
+3
source share
3 answers
RewriteRule ^members/([^/]+)/?$ members.php?id=$1 [L]

Just added "/?" in the end say seek tail slash but? says he should not be there.

+11
source

I don’t know anything about this " mod-rewrite" you are talking about (maybe the Apache module?), But it looks like regex and I know about it. :-)

Try the following:

RewriteRule ^members/([^/]+)(/|)$ members.php?id=$1 [L]

, , ^ " ", "members/" , ([^/]+) "1 , , $1", (/|) " , $2", $ " ".

+2

I just needed to extract the domain name, so I used this:

^(?:https?:\/\/)?(?:www[0-9]*\.)?(.*?)(?:\/.*)?$

In my table, it looks like this:

=REGEXEXTRACT(CELL_WITH_URL,"^(?:https?:\/\/)?(?:www[0-9]*\.)?(.*?)(?:\/.*)?$")

Hope this helps someone! Happy REGEXing!

0
source

Source: https://habr.com/ru/post/1727918/


All Articles