codeigniter htaccess的删除的index.php和WWWhtaccess、codeigniter、index、WWW

由网友(特烈朗姆酒)分享简介:我试图让我的htaccess重写规则来从URL中删除的index.php 键,也重定向 WWW。要求非www版本。这是我的htaccess它与取出的index.php正常工作:RewriteEngine叙述上的RewriteCond $ l ^(指数\ .PHP |资源|机器人\ .TXT)!的RewriteCon...

我试图让我的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]
 
扔掉Xlookup,我觉得INDEX XMATCH才是Excel中最强大的查找方式

但我只是不能似乎让他们很好地一起玩!任何意见/建议,大多数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.

阅读全文

相关推荐

最新文章