如何从URL中删除索引(PHP MVC)

时间:2018-08-03 18:50:59

标签: php .htaccess model-view-controller url-rewriting

我使用自己的php mvc我的htaccess:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

网站的URL如下:

test.com/blog/index/1

数字1:ID是数据库的列 如何从MVC网址中删除索引

谢谢

1 个答案:

答案 0 :(得分:0)

我是这样的

RewriteEngine on

#in case of SSL
#RewriteCond %{HTTPS} !=on
#RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond $1 !^(index\.php|public|\.txt|assets/images/fav/favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1