0

I'm having some problems with my .htaccess.

I have a link that's:

domain/view.php?pid=2

And I want to change it simply to:

domain/2

I don't have much knowledge with .htaccess and my attempts didn't work.

RewriteEngine On
RewriteRule ^(.*)$1 /view.php?pid=$1 [L]

I have another link that is

click.php?bid=2

and would like to transform it into

/out/2

Please note that my website (with exception of links view.php and click.php) works like: index.php?id=page1/2/3... Maybe it could be important in this thing. I just want to change view.php and click.php files.

Could someone help me? Thanks :)

Tiago
  • 567
  • 4
  • 14

1 Answers1

0

I think I got it. Could just someone check it to see if there's any big flaw or something?

RewriteEngine On
RewriteRule ^([A-Za-z0-9-\+]+)/?$ view.php?pid=$1 [NC,L,QSA]
RewriteRule ^out/([A-Za-z0-9-\+]+)/?$ click.php?bid=$1 [NC,L,QSA]
Tiago
  • 567
  • 4
  • 14
  • If bid and pid values are strictly integers, use just 0-9 in square brackets, `[0-9]` – Dusan Bajic Sep 18 '16 at 19:21
  • I've changed it but if the value doesnt exists gives an error. If I stay with all chars if the "ID" doesnt exist it redirects me to index what's intended for. If I only allow numbers if I type chars it doesnt redirect me to index and give error. Thanks :) – Tiago Sep 18 '16 at 19:44