androidAwesome
androidAwesome

Reputation: 57

Apache rewrite rule to make pretty URLs

I am trying to keep my URLs pretty.

Say we have the URL:

severhost.com/team/4325

In the team.php file I want the 4325 to be filled in $_GET["id"].

I have this rewrite rule:

RewriteRule ^/?team/([0-9]+)$ team.php?id=$1 [R]

but this actually changes the URL in the browser to be:

severhost.com/team.php?id=4325

I want the URL in the browser to remain severhost.com/team/4325.

Upvotes: 0

Views: 79

Answers (2)

androidAwesome
androidAwesome

Reputation: 57

RewriteRule ^/?team/([0-9]+)$ team.php?id=$1 [PS]

The flag needed to be set to [PS]

Upvotes: 0

Jonathan Kuhn
Jonathan Kuhn

Reputation: 15311

the [R] flag at the end of the rule means redirect. So what you are doing is telling it to redirect instead of rewrite the rule. You likely want to just change it to a [L].

Upvotes: 2

Related Questions