我如何在我的视图页面的url中删除/视图


How do I remove the /view in the url of my view page

我用codeigniter开发了我的网站jobgurus.com.ng。为了搜索引擎优化,我如何将视图页面url表单www.jobgurus.com.ng/jobs/view/system-support更改为www.jobgurus.com.ng/jobs/system-support

我想删除url中的/视图。

任何帮助将不胜感激。由于

您可以尝试在 .htaccess 文件中使用以下代码:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^view/(.*)$ /$1 [L,NC,R]

使用的标志说明:

L  -> Last
NC -> No case comparison
R  -> Redirection

备注:重定向默认代码为302。您可以通过设置 [L,NC,R=301] .

将其更改为301。

如果job为控制器名称,view为方法,则可以使用route of CI。在文件application/config/routes.php

中添加下面一行
 $route['job/(:any)'] = 'job/view/$1';

同样可以列出所有可能的链接