【发布时间】:2020-07-16 14:56:21
【问题描述】:
有没有办法使用没有htaccess的php代码获取url路径(例如index.php/sales,只提取'sales')? 我有一个 mvc 项目(使用 apache)并且工作正常,但不得不转移到使用 nginx 的 vagrant 服务器。从阅读中,我必须要么将 htaccess 规则转换为 nginx 服务器规则。但是盒子是预先配置了nginx的。不确定这里是否有工作。欢迎提出建议和解决方法。谢谢。
我的 htaccess 文件是:
RewriteBase /
RewriteCond %{REQUEST_FILENAME}% !-d
RewriteCond %{REQUEST_FILENAME}% !-f
# Do not route static files in the public directory
RewriteRule \.(js|css|svg|gif|jpg|jpeg|png)$ - [L]
RewriteRule ^/?editcategory/(.*?)/?$ /editcategory?categoryid=$1 [L]
# Route everything else to index.php in the public directory
# Note: name-router get variable used for public user profiles
RewriteRule ^(.*)$ index.php?name-router=$1 [QSA,L]
P.S:我对 nginx 很陌生,所以不想让事情变得更复杂。
【问题讨论】:
标签: php .htaccess url-routing