Christian Turkson
Christian Turkson

Reputation: 21

how do i rewrite url to remove ?id=13

Hello can anyone help me out being trying to remove some part of my url eg:

From this

http://localhost:8888/www.mysite.com/admin/account_expenses?return=account1

To this

http://localhost:8888/www.mysite.com/admin/account_expenses?

And I would like it still be able to $_GET['return'] value to echo error. and also how to apply to my other like that.

Thank you.

Upvotes: 2

Views: 129

Answers (3)

Vishnu Bhadoriya
Vishnu Bhadoriya

Reputation: 1676

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^?]*)\? 
RewriteRule ^(.*)$ http://www.example.com/admin/account_expenses? [R,L]

Try this instead for redirection to your page http://www.example.com/admin/account_expenses?

Upvotes: 0

ibonly
ibonly

Reputation: 133

One quick question is where is the URL coming from, is it from a form or from a link. If it is from a form, then your form attribute method="GET" should be method="POST". If it is from a link then you will use htaccess to format the URL as @vishnu stated.

Upvotes: 2

Vishnu Bhadoriya
Vishnu Bhadoriya

Reputation: 1676

RewriteCond %{QUERY_STRING} ^(.+)&return=[0-9a-z]+&(.+)$ [NC]
RewriteRule ^ %1 [R=301,L]

add this code to folders .htaccess file then you will able to get the variable value using $_GET without present paramenters in URL

Upvotes: 1

Related Questions