简体   繁体   中英

How to create virtual folders using php?

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

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM