简体   繁体   English

使用.htaccess在CodeIgniter中重写URL

[英]URL Rewriting in CodeIgniter using .htaccess

I am working on a project in which url Rewriting was done. 我正在完成url重写的项目。 Here is the link of the old uri 这是旧uri的链接

http://www.mysite.pk/jobs/search/faisalabad/all-cats

But now in the new url I have changed it to 但是现在在新网址中,我将其更改为

http://www.mysite.pk/jobs/pakistan/faisalabad/all-cats http://www.mysite.pk/jobs/巴基斯坦/ faisalabad / all-cats

what I want to do is to change the redirect all the url's whcih have http://www.mysite.pk/jobs/search/ search after job in them to the 我想做的是更改所有URL的重定向,使他们在工作后将http://www.mysite.pk/jobs/search/搜索到

http://www.mysite.pk/jobs/pakistan/

Here is my code of the route 这是我的路线代码

$route["jobs/pakistan"]="vacancies/search";

If you have any other solution then .htaccess kindly share it. 如果您还有其他解决方案,请.htaccess共享它。

.htaccess file use for remove index.php from base url following codes in .htaccess .htaccess文件用于根据.htaccess中的代码从基本URL中删除index.php

      RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond $1 !^(index\.php|images|robots\.txt)
  RewriteRule ^(.*)$ index.php?/$1 [L]

<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.     
  ErrorDocument 404 /index.php
</IfModule>

Rest your code are correct in route same 其余代码正确无误

$route["jobs/pakistan"]="vacancies/search";

$route["Link You Want"]="Actual path to access"; $ route [“想要的链接”] =“访问的实际路径”;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM