如何从基url编码器中删除尾随斜杠


How to remove the trailing slash from the base url codeigniter

我的主页url是http://localhost:8080/myproj/我需要删除末尾的斜杠我该怎么做?

因为,当我删除index.php(使用htaccess), url变成http://localhost:8080/myproj//projects/listurl需要是这样的http://localhost:8080/myproj/projects/list

请帮

你的代码应该如下

echo site_url('projects/list')

试试这个

尝试使用这个。htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

这个指南应该是有帮助的。http://www.htaccess-guide.com/

在config目录中打开config.php文件,检查base URL应该为

$config['base_url'] = 'https://yoursite.com/';

,现在像这样访问任何控制器:-

echo site_url('controller/function');