RNK
RNK

Reputation: 5792

URL rewrite with .htaccess (remove $_GET variables)

I have this URL : https://example.com/beehive_deposit?id=6a23361b37MjE-&owner_cus_id=607dde5711MQ--

And I want to convert it in this:

https://example.com/beehive_deposit/6a23361b37MjE-/607dde5711MQ--

I am using codeigniter framework in PHP.

I tried something like this in .htaccess:

RewriteEngine on
RewriteBase /
RewriteRule ^beehive_deposit/([^/.]+)/?$ beehive_deposit?id=$1 [L,QSA,NC]

HTML:

<a href="/beehive_deposit?id=b5347cb1cdMjE-&amp;owner_cus_id=d6cc12707fMQ--"></a>

Upvotes: 1

Views: 415

Answers (1)

Marc B
Marc B

Reputation: 360762

You're going about it wrong. The URLs you output to client-side HTML should already be in the "clean" format:

<a href="https://example.com/beehive_deposit/6a23361b37MjE-/607dde5711MQ--"></a>

And then your rewrite rule becomes (basically):

RewriteRule ^beehive_deposit/(.*)/(.*)$ beehive_deposit.php?id=$1&cus_id=$2

Upvotes: 4

Related Questions