codeigniter htaccess的删除的index.php和WWW [英] Codeigniter htaccess to remove index.php and www

查看:244
本文介绍了codeigniter htaccess的删除的index.php和WWW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的htaccess重写规则来从URL中删除的index.php 键,也重定向 WWW。要求非www版本。

这是我的htaccess它与取出的index.php正常工作:

  RewriteEngine叙述上
的RewriteCond $ l ^(指数\ .PHP |资源|机器人\ .TXT)!
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php / $ 1 [L,QSA]
 

和我碰到了如何删除 WWW 部分另一个问题:

  RewriteEngine叙述上
的RewriteCond%{} HTTPS!=上
的RewriteCond%{HTTP_HOST} ^ WWW \。(。+)$ [NC]
重写规则^ $ HTTP(*)://%1 / $ 1 [R = 301,L]
 

但我只是不能似乎让他们很好地一起玩!任何意见/建议,大多数AP preciated!

解决方案

  RewriteEngine叙述上
的RewriteCond%{} HTTPS!=上
的RewriteCond%{HTTP_HOST} ^ WWW \。(。+)$ [NC]
重写规则^ $ HTTP(*)://%1 / $ 1 [R = 301,L]

的RewriteCond $ l ^(指数\ .PHP |资源|机器人\ .TXT)!
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php / $ 1 [L,QSA]
 

RewriteEngine叙述在启动重写。 的RewriteCond 重写规则工作对。 在这里,我们给用户以非www版本,第一,并清理网址。

I'm trying to get my htaccess rewrite rules to remove the index.php from the url AND also redirect the www. requests to the non-www version.

This is my htaccess which works fine with removing the index.php:

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

And I came across another question on how to remove the www part:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

But I just cant seem to get them to play nicely together! Any advice/suggestions most appreciated!

解决方案

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

RewriteEngine On "starts" rewriting. RewriteCond and RewriteRule work as pairs. Here, we send user to non-www version first, and cleans URLs.

这篇关于codeigniter htaccess的删除的index.php和WWW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆