URL with fixed and variable parameter

Asked

Viewed 68 times

1

Hello, I’m having trouble getting my htaccess file right, and I have a fixed parameter that I pass manually and one that depends on the user when I click and change Uf, follow the example

RewriteRule ^representantes\/(.*)$ representantes.php?i_page=3&uf=$1

The UF parameter would depend on the user when clicking on a link and changing the state (Uf) the i_page would be fixed. The URL would look like this:

https://teste.com/representantes

https://teste.com/representantes?uf=SC

UPDATE

I tried something like

RewriteRule ^representantes?uf=(.*)$ representantes.php?i_page=3&uf=$1

but I still did not have the expected result.

  • Would be /representantes?uf=SC or /representantes/SC? Can you confirm if you put the question right? The text asks one thing, the code shows another. That would be the question?

  • would be so /representatives? Uf=SC, even put the example to have no doubts

1 answer

0


After much research I found a solution:

RewriteRule ^representantes?(.*)$ representantes.php?i_page=3&uf=$1 [QSA,L]

this rule sends the fixed parameter and the UF, so I can redeem the values by $_GET. And also removes . php from the url making it more friendly.

Browser other questions tagged

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