开发者

CodeIgniter htaccess from folder to root

开发者 https://www.devze.com 2023-03-18 22:56 出处:网络
There are a number of people who have bookmarked a site that had a URL like this:http://www.domain.com/map/.

There are a number of people who have bookmarked a site that had a URL like this: http://www.domain.com/map/.

This morning we changed the content that was in the map folder to the root. I have been trying to write an htaccess for codeigniter to eliminate the index.php and redirect from the map folder to the root.

I have not been successful

I have this so far -- 开发者_如何学Goconn is my default controller

RewriteEngine On
RewriteBase /

RewriteRule ^(conn(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
rewriteCond %{http_host} ^domain.com/map/
rewriteRule ^(.*)$ http://www.domain.com/ [r=301,nc] 


Use this rule:

RewriteRule ^map/$ http://www.example.com/ [R=301,L]

The rule above will take all hits to http://www.example.com/map/ and redirect (301 Permanent Redirect) them to the root folder: http://www.domain.com/.

It will work for THAT URL ONLY (which means that hit to http://www.example.com/map/somepage will NOT be redirected. If you need to redirect ALL URLS in /map/ folder to a root, then remove $ from that rule.

P.S. Keep in mind that order of rewrite rules matters, so place this rule above your CodeIgniter rewrite rules (if any) -- possibly just below RewriteBase one.

0

精彩评论

暂无评论...
验证码 换一张
取 消