.htaccess detect string after Slash

Asked

Viewed 26 times

1

I’m not getting htaccess to detect string or characters after / for example.

I have this:

foo.foo/xx/

and I wanted when this happened

foo.foo/xx/whatever

o . htaccess internally executes a php code

I tried it but unsuccessfully

RewriteEngine on 
RewriteRule ^(.*)/xx/$ https://www.google.com/ [L] 

1 answer

2


Your Regex does not contemplate what you wish.

She says she can have anything but must end with /xx/.
And what you want is anything + /xx/ + anything.

That would be so : (.*)/xx/(.*).

I personally do not think this kind of Regex good, because it is not clear enough. So the only thing it says is that it should contain /xx/.

Can accept :

xpto.xpto/xx/qualquecoisa/xx/qualquecoisa
xpto.xpto/xx/xx/
xpto.xpto/xx//xx/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.