GVKun编程网logo

Codeigniter htaccess删除index.php和www(怎么删除index.html)

20

在本文中,您将会了解到关于Codeigniterhtaccess删除index.php和www的新资讯,同时我们还将为您解释怎么删除index.html的相关在本文中,我们将带你探索Codeignit

在本文中,您将会了解到关于Codeigniter htaccess删除index.php和www的新资讯,同时我们还将为您解释怎么删除index.html的相关在本文中,我们将带你探索Codeigniter htaccess删除index.php和www的奥秘,分析怎么删除index.html的特点,并给出一些关于5 .htaccess重写:强制HTTPS,删除index.php,删除.php,强制www,强制尾随斜杠、CodeIgniter .htaccess index.php重写不在用户目录上工作、CodeIgniter .htaccess – 500内部服务器错误/ index.php删除、codeigniter 3.0 nginx 去除index.php的实用技巧。

本文目录一览:

Codeigniter htaccess删除index.php和www(怎么删除index.html)

Codeigniter htaccess删除index.php和www(怎么删除index.html)

我试图让我的htaccess重写规则从url中删除index.PHP ,也redirectwww. 请求到非www版本。

这是我的htaccess工作正常与删除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]

我遇到了另一个关于如何删除www部分的问题:

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

但我似乎不能让他们一起打好! 任何意见/build议最高度赞赏!

将Apache .htaccess转换为Nginx

在.htaccess中需要一个特定的URL RewriteRule

Apache多重写规则

.htaccess使用UTF 8字符redirectURL

将rootredirect到subdir中的CodeIgniter应用程序,避免无限循环

.htaccess重写规则冲突

htaccess将别名redirect到主域

简单的mod_rewriteredirect

如何通过使用`RewriteRule ^(。*)$?id = $ 1 `获取文件目录槽.htaccess?

htaccess重写条件/查找文件名中的模式

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 “开始”重写。 RewriteCond和RewriteRule成对使用。 在这里,我们首先发送用户到非www版本,并清除URL。

您首先需要确保“非www”重写规则是第一个,然后是将所有请求重定向到CodeIgniter引导文件的规则。 请注意,下面的代码将只承认HTTP重写。 如果您还需要HTTPS,则需要进行一些修改。

RewriteEngine on # Sending all www requests to the non-www version. RewriteCond %{HTTP_HOST} ^www.domain.com [NC] RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301] # Now the CodeIgniter part RewriteCond $1 !^(index.PHP|resources|robots.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.PHP/$1 [L,QSA]

5 .htaccess重写:强制HTTPS,删除index.php,删除.php,强制www,强制尾随斜杠

5 .htaccess重写:强制HTTPS,删除index.php,删除.php,强制www,强制尾随斜杠

我已经阅读了很多文章,似乎无法将所有组合的.htaccess重写一起工作.我要么重新直接循环,要么一个或几个根本不起作用.

为了清楚起见,我正在寻找以下5个,如果需要的话:

>确保所有网址上的www
>确保所有版本站点的HTTPS
>从url中删除index.PHP
>删除所有.PHP扩展名/重定向到没有.PHP扩展名的网址
>可以与前一个一起:添加尾部斜杠

一些例子:

> example.com/index.PHP => https://www.example.com/
> www.example.com/info/really-good-info.PHP => https://www.example.com/info/really-good-info/
> www.example.com/about-us.PHP => https://www.example.com/about-us/
> www.example.com/careers/index.PHP => https://www.example.com/careers/

这是当前的.htaccess设置:

<IfModule mod_rewrite.c>
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /

# Remove all .PHP extensions without interfering with .js or .css.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.(?!js|css)([^.]*)$$1\.PHP

# Remove index from url.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$index?$1 [L,QSA]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.PHP [NC]
RewriteRule ^ %1 [R=301,L]

# Ensure www on all URLs.
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$https://www.example.com/$1 [L,R=301]

# Ensure we are using HTTPS version of the site.
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Ensure all URLs have a trailing slash.
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$https://www.example.com/$1/ [L,R=301]

</IfModule>

上面的.htaccess只在我的根文件夹中,目前需要5个中的3个:更改为HTTPS,添加www并删除index.PHP.它不会删除任何其他.PHP文件扩展名,也不会添加尾部斜杠.

解决方法:

我看到2个问题:

重写规则后重定向规则出现
只有在确保存在相应的.PHP文件后才能添加.PHP.

这样做:

Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /

# Ensure www on all URLs.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$https://www.%{HTTP_HOST}/$1 [L,R=302]

# Ensure we are using HTTPS version of the site.
RewriteCond %{HTTPS} !on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]

RewriteCond %{THE_REQUEST} \s/*(.*?)/index\.PHP [NC]
RewriteRule ^ %1/ [R=302,L]

RewriteCond %{THE_REQUEST} \s/+(.+?)\.PHP[\s?] [NC]
RewriteRule ^ /%1/ [R=302,L]

# Ensure all URLs have a trailing slash.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[^.]*?[^/.]$%{REQUEST_URI}/ [L,R=302]

# Remove all .PHP extensions without interfering with .js or .css.
RewriteCond %{REQUEST_FILENAME}.PHP -f
RewriteRule ^([^.]+?)/?$$1.PHP [L]

# Remove index from url.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+?)/?$index.PHP?$1 [L,QSA]

在测试之前,请务必清除浏览器缓存.

CodeIgniter .htaccess index.php重写不在用户目录上工作

CodeIgniter .htaccess index.php重写不在用户目录上工作

我有一个与codeigniter有点问题,我有一个.htaccess重写index.PHP它工作得很好,如果我把我的项目在/ var / www或如果我做一个虚拟主机。

但是我想使用我的用户目录,如http:// localhost /〜userdir / myproject 。 如果我使用我的用户目录,当我试图请求一个控制器,如: http:// localhost /〜userdir / myproject /注册我得到这个错误:

未find

在此服务器上未find请求的URL /index.PHP。

Zend和.htaccess

重写引擎.htaccess MIMEtypes错误

.htaccess的子域名重写

Apache文件夹没有显示出来

如何防止在htaccess无限redirect循环?

这是我目前的configuration:

的.htaccess

RewriteEngine on RewriteCond $1 !^(index.PHP|(.*).swf|forums|images|css|downloads|jquery|js|robots.txt|favicon.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.PHP?/$1 [L,QSA]

应用/configuration/ config.PHP中

$config[''base_url''] = ''''; $config[''index_page''] = ''''; $config[''uri_protocol''] = ''AUTO''; $config[''encryption_key''] = ''myencryption_key''; //all remaining is the default config

这个configuration在http:// localhost /上的效果很好,而且在http://example.com/这个域中的生产环境上,但是在我的用户目录http:// localhost /〜userdir / project /

我做错了什么? 有什么想法吗? 提前致谢。

redirect规则与特殊字符

Laravel 4虚拟主机和mod重写设置

由于网页转发,浏览器url栏中的url会迅速变化

使用htaccess拒绝ajax文件访问

有没有可能在.htaccess文件中输出任何或所有可用的variables?

好吧,我在codeigniter论坛中找到了一个解决方案,首先我需要添加RewriteBase行如下:

RewriteBase /~userdir/myproject/

然后,删除最后一行index.PHP之前的斜杠。

RewriteRule ^(.*)$ index.PHP?/$1 [L,QSA]

有人这样说

RewriteCond $1 !^(index.PHP|(.*).swf|forums|images|css|downloads|jquery|js|robots.txt|favico​​n.ico)

是多余的,下面两行代码覆盖它,

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d

和所有其他真实的文件/目录。 他们基本上说:“如果请求不是一个真正的文件,并且请求不是一个真正的目录,请将请求传递给index.PHP。大概所有从上面的行是一个真正的文件或目录,所以这是不需要的所有。

所以,我的最终.htaccess是这样的:

RewriteEngine on RewriteBase /~userdir/myproject/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.PHP?/$1 [L,QSA]

它可以在http:// localhost /〜userdir / myproject的本地工作,也可以通过http://example.com/~userdir/myproject制&#x4F5C;

你需要像这样删除第一个斜杠berfore index.PHP

RewriteRule ^(.*)$ index.PHP?/$1 [L,QSA]

本地解决方案

RewriteEngine On RewriteBase /ci/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /ci/index.PHP/$1 [L]

在线解决方案 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.PHP?/$1 [L]

总结

以上是小编为你收集整理的CodeIgniter .htaccess index.php重写不在用户目录上工作全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

CodeIgniter .htaccess – 500内部服务器错误/ index.php删除

CodeIgniter .htaccess – 500内部服务器错误/ index.php删除

我有一个这样的网站(子域)

rabbani.websolocom.xyz

我有这样的.htaccess代码(我使用Codeigniter):

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

但是当我尝试访问我的网站时,出现错误(500内部服务器错误)。 我应该如何处理我的.htaccess文件? 或者我的目录中有任何其他文件错误?

如何指向所有子域index.PHP

将文件夹redirect到包含文件夹的子域

透明redirect到端口8080

从子目录中重写一个PHP参数的URL

.htaccess mod_rewrite基于IP的redirect:如何将所有stream量redirect到特定的子目录,除了我的IP?

.htaccess强制HTTPS

CORS问题请求的资源上没有“Access-Control-Allow-Origin”标题

有没有机会在litespeed或apache中使用Nginx HttpAccessKeyModule?

在htaccess中禁用PHP函数

使用.htaccess用正斜线replaceURL中的反斜线

用这个

.htaccess (外部应用程序文件夹)

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.PHP/$1 [L,QSA]

这是Codeigniter推荐的.htaccess

将.htaccess放入rabbani文件夹中

RewriteEngine on RewriteBase / RewriteCond %{REQUEST_URI} !.[^./]+$ RewriteCond %{REQUEST_URI} !(.*)/$

试试这两个htaccess

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

RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*).domain.com RewriteRule ^(.*)$ http://domain.com/%1/$1 [L,NC,QSA]

这里更多的htaccess。

这是我的新.htaccess

<Ifmodulee mod_rewrite.c> RewriteEngine On # !IMPORTANT! Set your RewriteBase here and don''t forget trailing and leading # slashes. # If your page resides at # http://www.example.com/mypage/test1 # then use # RewriteBase /mypage/test1/ RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.PHP?/$1 [L] </Ifmodulee>

试试这个:如果你在本地系统上使用codeigniter

<Ifmodulee mod_rewrite.c> RewriteEngine On RewriteBase /projectfolder/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /projectfolder/index.PHP/$1 [L] </Ifmodulee>

如果你在服务器上使用它,那么使用这个:

<Ifmodulee mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.PHP/$1 [L] </Ifmodulee>

总结

以上是小编为你收集整理的CodeIgniter .htaccess – 500内部服务器错误/ index.php删除全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

codeigniter 3.0 nginx 去除index.php

codeigniter 3.0 nginx 去除index.php

因为要配合泰分活动方,需要把index.php去除调,NG配置代码如下:

location /

        {

            index index.php;

            if (!-e $request_filename) {

                 rewrite ^/(.*)$ /index.php?$1 last;

                 break;

            }

        }


关于Codeigniter htaccess删除index.php和www怎么删除index.html的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于5 .htaccess重写:强制HTTPS,删除index.php,删除.php,强制www,强制尾随斜杠、CodeIgniter .htaccess index.php重写不在用户目录上工作、CodeIgniter .htaccess – 500内部服务器错误/ index.php删除、codeigniter 3.0 nginx 去除index.php等相关内容,可以在本站寻找。

本文标签: