如何使用 php 创建虚拟文件夹?
How to create virtual folders using php?
我正在使用 php 和 aws elasticbeanstalk。
我想创建接受此 url :
的文件夹
www.example.com/481818
其中 481818 表示已更改的 ID。
所以我想创建一个文件来接受来自这个结构的每个请求www.example.com/integer
。并获取 ID。
我不知道如何创建这个文件。
我可以用这个 url : www.example.com/?id=4545454
来完成。但我不想要这个 url 结构。
谢谢
将此放入您的 .htaccess
文件
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([0-9]+)$ index.php?id= [NC,L]
</IfModule>
它应该做你想要的,我以前没有用过elastic-beanstalk,希望我能帮助你。
您必须将所有不存在的 URL 重写为脚本。在 Apache 上,您可以将这些规则添加到 www 根目录中的 .htaccess
文件中。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)$ /index.php?id= [L]
</IfModule>
我正在使用 php 和 aws elasticbeanstalk。 我想创建接受此 url :
的文件夹www.example.com/481818
其中 481818 表示已更改的 ID。
所以我想创建一个文件来接受来自这个结构的每个请求www.example.com/integer
。并获取 ID。
我不知道如何创建这个文件。
我可以用这个 url : www.example.com/?id=4545454
来完成。但我不想要这个 url 结构。
谢谢
将此放入您的 .htaccess
文件
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([0-9]+)$ index.php?id= [NC,L]
</IfModule>
它应该做你想要的,我以前没有用过elastic-beanstalk,希望我能帮助你。
您必须将所有不存在的 URL 重写为脚本。在 Apache 上,您可以将这些规则添加到 www 根目录中的 .htaccess
文件中。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)$ /index.php?id= [L]
</IfModule>