0

I have a website with a dynamic structure: for every $_GET['action'] I include a file with a different content, while the footer and the header always remain the same. example: www.mysite.com/index.php?action=service1 I would like to change this "structure" in a way: www.mysite.com/service1/ is there a way to include the $_GET['action'] request in every folder I create?

The site in question has over 100+ $_GET['action'] and creating a page for each action would become heavy .

any advice on how to do?

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
Criniti
  • 41
  • 1

1 Answers1

1

You can set up your .htaccess to pipe certain values to your $_GET variables.

Learn more here.

The basic idea is to add something like:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^service/(\d+).*$ ./myActionscript.php?id=$1 [L]

Then all requests you send to /service/{number} will go to your file myActionScript and you can do what you want with that {number} there by using string manipulation on the $_SERVER['REQUEST_URI'] to get it.

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
LiefdeWen
  • 586
  • 2
  • 14