我正在为PHP项目的本地主机工作。我需要一些解决办法。
当前URL: http://localhost/project/portfolio/php_files/port_sub_sidebar.php?x=opencart
现在,我想在URL中这样显示:http://localhost/project/portfolio/opencart
怎么可能在。htaccess文件中做改变
In .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(.*)('.jpg|'.gif|'.png|'.css|'.js)$
RewriteRule ^(.+)$ index.php?url=$1 [L,QSA]
你可以通过下面的代码获得url
$url = $_GET['url'];
$segments = explode("/",$url);
print_r($segments);
,那么你就可以基于提供的段