如何设置URL而不显示控制器和函数名称
How to set URL without displaying controller and function name
我要显示这个URL,
http://localhost/cosmetics2/index.php/Services/index
不显示控制器名称和功能名称...
那么该怎么做,你能告诉我如何解决这个问题吗...
尝试编辑到您的 route.php
文件的路径,您可以在 application/config/route.php
中找到它。
添加像 $route['mycustomurl'] = 'Services/index'
这样的行之后;而你的 url 就像 http://localhost/index.php/mycustomurl
。
有关 codeigniter 路由的更多详细信息,请随时阅读文档 https://www.codeigniter.com/userguide3/general/routing.html。
if you want to remove index.php
This would help CodeIgniter removing index.php from url
我们可以为此使用路由,在您的 application/config/routes.php
.
看例子,
$route['route_name_you want_to_Show'] = 'Services/index';
如果你想删除 index.php 然后将下面的代码添加到 .htaccess
htaccess
RewriteEngine On
RewriteBase /ci/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
ErrorDocument 404 /index.php
我要显示这个URL,
http://localhost/cosmetics2/index.php/Services/index
不显示控制器名称和功能名称... 那么该怎么做,你能告诉我如何解决这个问题吗...
尝试编辑到您的 route.php
文件的路径,您可以在 application/config/route.php
中找到它。
添加像 $route['mycustomurl'] = 'Services/index'
这样的行之后;而你的 url 就像 http://localhost/index.php/mycustomurl
。
有关 codeigniter 路由的更多详细信息,请随时阅读文档 https://www.codeigniter.com/userguide3/general/routing.html。
if you want to remove
index.php
This would help CodeIgniter removing index.php from url
我们可以为此使用路由,在您的 application/config/routes.php
.
看例子,
$route['route_name_you want_to_Show'] = 'Services/index';
如果你想删除 index.php 然后将下面的代码添加到 .htaccess
htaccess
RewriteEngine On
RewriteBase /ci/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
ErrorDocument 404 /index.php