Dynamic friendly URL . htaccess

Asked

Viewed 256 times

0

I currently have the following rule in . htaccess:

RewriteRule ^fale-conosco/?$ view/fale_conosco.php [NC,L]

And I would like it to be possible to inform a friendly URL after contacting us/.

Example:

fale-conosco/ajuda

For this I am using a regex but it is not working:

/^fale-conosco\/*([a-zA-Z0-9])*/g

I have tried several regular expressions but so far nothing has worked.

When I tested in the rule gave error when I added localhost in front of the rest of the URL, such as ignoring what is in front of the fale-conosco/?

1 answer

1


[EDIT]

Ignore the before and pass the after by parameter: RewriteRule ^(.*)/fale-conosco/(.*)?$ view/fale_conosco.php?parametro=$2 [NC,L].

I forgot to explain: the first (.*) get something before /fale-conosco (which is stored in $1), the second (.*) take everything after /fale-conosco, which gets into $2.


You can by RewriteRule ^fale-conosco/.*?$ view/fale_conosco.php [NC,L]. All after fale-conosco/ will be ignored.

I tested on this site: https://htaccess.madewithlove.be/

  • 1

    I need what’s before the fale-conosco/ is ignored and whatever is after it I will pass by parameter.

  • I changed the answer, it worked?

  • 1

    It took me a long time to answer because I forgot, but it did work...

Browser other questions tagged

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