How to create virtual folders using php?

360 views Asked by At

I am using php with aws elasticbeanstalk. I want to create folder that accept this url :

www.example.com/481818

where 481818 present an id that is changed.

so i want to create file that accept every request form this structure www.example.com/integer. and fetch the id.

i don't know how to create this file.

I can do it with this url : www.example.com/?id=4545454 . but I don't want this url structure.

thank you

2

There are 2 answers

0
Hartman On BEST ANSWER

Put this in you .htaccess file

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteRule ^([0-9]+)$ index.php?id=$1 [NC,L]
</IfModule>

It should do what you want, I didn't use elastic-beanstalk before, hopes I can help you.

0
umka On

You have to rewrite all non-existent URLs to a script. On Apache you can make it adding these rules to .htaccess file in your www root.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)$ /index.php?id=$1 [L]
</IfModule>