0

how can i rewrite /index.php?f=test to /test

example : domain.com/?f=test to domain.com/test

and I want to receive in PHP data as GET Request

<?php 

$file = $_GET['f'];

// if url was domain.com/test/ $file must be test 

?>
Jamal Abo
  • 433
  • 3
  • 15
  • 1
    Possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](https://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – Croises Aug 28 '17 at 14:10
  • Can you please share What you have tried? – Amit Verma Aug 28 '17 at 14:10
  • the latest one is RewriteEngine On RewriteRule ^([A-Za-z0-9-]+) index.php?f=$1 and php result is index – Jamal Abo Aug 28 '17 at 14:11
  • Please dont post your code in the comment area. edit your question to post the code. – Amit Verma Aug 28 '17 at 14:13

1 Answers1

0

The index you are getting on your php file is because of the unconditional rule. your rule is causing an infinite redirect/double redirect. You need to exclude your existent files from the rule .

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?f=$1
Amit Verma
  • 38,175
  • 19
  • 80
  • 104