Codeigniter htaccess Url重写

时间:2015-08-21 22:10:56

标签: .htaccess codeigniter mod-rewrite

当我点击此网址时:

http://dev.project.com/my-site

它将我重定向到

http://dev.project.com/my-site/en

我想从网址中删除“EN”后缀,但它应该转到“en”版本。我的htaccess在下面 - 有人可以帮助我吗?

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /my-site/index.php?/$1 [L,QSA]
</IfModule>

1 个答案:

答案 0 :(得分:0)

试试这个.htacess

# Remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]

# To externally redirect /dir/file.php to /dir/file
RewriteCond %{THE_REQUEST} \s/+(?:index)?(.*?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]

# Don't require .php extension to load php page
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ /$1.php [L]