GVKun编程网logo

Codeigniter URL重写.htaccess在CentOS上不起作用(url重写技术)

25

本文将带您了解关于CodeigniterURL重写.htaccess在CentOS上不起作用的新内容,同时我们还将为您解释url重写技术的相关知识,另外,我们还将为您提供关于base_url()函数在

本文将带您了解关于Codeigniter URL重写.htaccess在CentOS上不起作用的新内容,同时我们还将为您解释url重写技术的相关知识,另外,我们还将为您提供关于base_url()函数在codeigniter中不起作用、CentOS下.htaccess不起作用的解决方法、CodeIgniter .htaccess index.php重写不在用户目录上工作、CodeIgniter .htaccess – 500内部服务器错误/ index.php删除的实用信息。

本文目录一览:

Codeigniter URL重写.htaccess在CentOS上不起作用(url重写技术)

Codeigniter URL重写.htaccess在CentOS上不起作用(url重写技术)

我在/var/www/html/文档根目录下创build了一个.htaccess文件来重写Codeigniter的URL,以从所有页面的URL中删除“index.PHP”。

例如,更改URL

http://myhost/index.PHP/controller/function

http://myhost/controller/function`

这是我的`/var/www/html/.htaccess的代码

URL重写和redirect(使用数据库数据)

index.PHP查询参数的.htaccess中的URL RewriteRule

CodeIgniter的htaccess子文件夹问题

.htaccess与片段redirect

用查询stringhtaccess RewriteRule页面

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

我有很多使用googling来启用mod-rewrite模块的build议,但是我可以在我的httpd.conf看到它已经启用了。

LoadModule rewrite_module modules/mod_rewrite.so

这在我的本地系统上运行在Debian 7(Apache / 2.4.4)上是完美的。

任何帮助,将不胜感激。

总结

以上是小编为你收集整理的Codeigniter URL重写.htaccess在CentOS上不起作用全部内容。

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

base_url()函数在codeigniter中不起作用

base_url()函数在codeigniter中不起作用

在我的Web应用程序中使用codeigniter。我正在尝试使用base_url()函数,但显示为空结果。我也通过自动加载文件使用了自动加载帮助器,但是它似乎也不起作用。我也定义了基本常数,但是都没有用。

<html xmlns="http://www.w3.org/1999/xhtml">    <head>        <title><?php echo $title; ?></title>                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>        <link rel="stylesheet" href="<?php echo base_url();?>/css/template/default.css" type="text/css" />        <script type="text/javascript">            //<![CDATA[            base_url = ''<?= base_url();?>'';            //]]>        </script>    </head>

答案1

小编典典

为了使用base_url(),您必须首先加载URL
Helper。可以application/config/autoload.php在第67行(或第67行附近)完成此操作:

$autoload[''helper''] = array(''url'');

或者,手动:

$this->load->helper(''url'');

加载后,请切记base_url()不要隐式打印或回显任何内容,而是返回要打印的值:

echo base_url();

还请记住,返回的值是配置文件中提供的网站的基本URL。CodeIgniter还将在配置文件中容纳一个空值:

如果未设置(base_url),则CodeIgniter将猜测安装的协议,域和路径。

application / config / config.php,第13行

CentOS下.htaccess不起作用的解决方法

CentOS下.htaccess不起作用的解决方法

结果点击一个链接直接404 Not Found。悲剧,看来Apache的Rewrite部分有问题了,完全无视掉了.htaccess文件!经过检查Apache的模块,发现Rewrite模块是开启的状态,看来是httpd.conf文件中的配置有点问题了。回想起之前在Ubuntu Server下配置Rewrite也是启用了一个叫做“AllowOverride”的属性为“All”才正确开启了Rewrite,这次手动配置VirtualHost的时候并没有写上这两句,看来就是这个问题了。

立马输入 :

#vim /etc/httpd/conf/httpd.conf
找到自己的VirtualHost设置部分,添上

<Directory />
AllowOverride All
</Directory>
上面这段的Directory /的“/”为你的www路径,如放在“/var/www/html”路径下就写为“<Directory /var/www/html>”,以此类推。保存后重启httpd服务:

#/etc/init.d/httpd restart
再次进入WordPress,点击一个链接,成了!问题解决。看来这个“AllowOverride”很不简单啊!于是上网找了一圈,发现这个是控制.htaccess的关键点所在。除了需要在Apache中打开Rewrite,以及正确设置.htaccess文件名之外,还需要对目录的AllowOverride进行配置,因为默认情况下AllowOverride值为None,这样会完全忽略.htaccess文件。

此外,除了All和None这两个值之外,AllowOverride还有很多个值,他们的含义分别如下:

AuthConfig
允许使用与认证授权相关的指令(AuthDBMGroupFile, AuthDBMUserFile, AuthGroupFile, AuthName, AuthType, AuthUserFile, Require, 等)。

FileInfo
允许使用控制文档类型的指令(DefaultType, ErrorDocument, ForceType, LanguagePriority, SetHandler, SetInputFilter, SetOutputFilter, mod_mime中的 Add* 和 Remove* 指令等等)、控制文档元数据的指令(Header, RequestHeader, SetEnvIf, SetEnvIfNoCase, BrowserMatch, CookieExpires, CookieDomain, CookieStyle, CookieTracking, CookieName)、mod_rewrite中的指令(RewriteEngine, RewriteOptions, RewriteBase, RewriteCond, RewriteRule)和mod_actions中的Action指令。

Indexes
允许使用控制目录索引的指令(AddDescription, AddIcon, AddIconByEncoding, AddIconByType, DefaultIcon, DirectoryIndex, FancyIndexing, HeaderName, IndexIgnore, IndexOptions, ReadmeName, 等)。

Limit
允许使用控制主机访问的指令(Allow, Deny, Order)。

Options[=Option,...]
允许使用控制指定目录功能的指令(Options和XBitHack)。可以在等号后面附加一个逗号分隔的(无空格的)Options选项列表,用来控制允许Options指令使用哪些选项。

这样以来,加上All和None,一共是7个可选的值了。看来又增长了不少的见识呀!以后再出现类似问题,不管哪个Linux下,我都能轻松找到问题所在了!
您可能感兴趣的文章:
  • CentOS 6.6实现永久修改DNS地址的方法
  • Centos下IP与DNS设置方法详解
  • 用DNSPod和Squid打造自己的CDN (三) 安装CentOS Linux
  • Centos 6.3将Mysql 5.1.61升级为mysql 5.6.19遇到的问题及解决方式
  • CentOS下php使用127.0.0.1不能连接mysql的解决方法
  • CentOS安装pillow报错的解决方法
  • CentOS 7下MySQL服务启动失败的快速解决方法
  • centos下编译安装mysql报错解决方案
  • CentOS下PHP7的编译安装及MySQL的支持和一些常见问题的解决办法
  • Centos修改DNS重启或重启network服务后丢失问题解决方法

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 URL重写.htaccess在CentOS上不起作用url重写技术的分享已经结束,谢谢您的关注,如果想了解更多关于base_url()函数在codeigniter中不起作用、CentOS下.htaccess不起作用的解决方法、CodeIgniter .htaccess index.php重写不在用户目录上工作、CodeIgniter .htaccess – 500内部服务器错误/ index.php删除的相关知识,请在本站进行查询。

本文标签: