我正在尝试为我的网站创建一个漂亮的网址结构.
我的路由器类只有在url的样式为?something = value时才有效.
我怎么得到它所以它会像:
/something/value
在我的.htaccess中我有:
Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|txt|gif|jpg|png)$index.php?$1 [L,QSA]
在我的路由器类中,我正在制作:
class init {
function __construct()
{
$URL = substr($_SERVER['REQUEST_URI'], 19) ;
$URLElements = explode('/', $URL) ; // Adjust if needed.
$class = $URLElements[0] ;
$method = $URLElements[1] ;
if(($t = substr_count($URL, '/')) > 1)
{
for($i=2;$i
echo $URLElements[$i].'
';
}
}
}
}
感谢杰森,我的.htaccess现在只是:
FallbackResource /t2013/public_html/index.php
解决方法:
FallbackResource /index.php
标签:htaccess,php,url-routing,apache,front-controller
来源: https://codeday.me/bug/20190723/1511167.html