Codeigniter htaccess和base_url [英] Codeigniter htaccess and base_url

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

问题描述

我安装codeigniter并开始写一些代码on it.First我想删除index.php并进行一些研究。我删除它与一个小的htaccess代码,

  RewriteEngine on 
RewriteCond $ 1!^(index\.php | images | css | robots\.txt)
RewriteRule ^ )$ /pasaj/index.php/$1 [L]

然后在config中设置我的base_url。 php as,

  $ config ['base_url'] ='http:// localhost / pasaj /'; 

然后我决定在表单的动作中使用base_url


$ b $

 < form method =postid = formSubmitname =fSubmitaction =<?php base_url(); >kayit / kayitOnay /> 

但不起作用



打印类似的网址



我做的一切都不工作



我怀疑从我的htaccess文件。我删除它。我用它在codeigniter默认情况下删除index.php。



并设置我的新
基本url一样

  http://localhost/pasaj/index.php/ 

并且不要更改表单代码以上的任何内容



并且可以正常工作。



想仍然使用这个htaccess文件为了删除index.php,但当htaccess文件存在我的base_url工作不正确。 htaccess文件中的更改可能是什么?

解决方案

试试这个

  RewriteEngine on 
RewriteBase / pasaj /
RewriteCond $ 1!^(index\.php | images | css | robots\.txt)
RewriteRule ^(。*)$ index.php / $ 1 [L]



本地服务器上的htaccess文件如下所示:



对于Zend Framework网络:

  RewriteEngine On 
RewriteCond%{REQUEST_FILENAME } -s [OR]
RewriteCond%{REQUEST_FILENAME} -l [OR]
RewriteCond%{REQUEST_FILENAME} -d
RewriteRule ^。* $ - [NC,L]
RewriteRule ^。* $ index.php [NC,L]

对于CodeIgniter web:

  RewriteEngine on 
RewriteBase / pasaj /
RewriteCond%{REQUEST_FILENAME}!-f
RewriteCond% REQUEST_FILENAME}!-d
RewriteRule ^(。*)$ index.php?/ $ 1 [L]
RewriteRule。* - [E = REMOTE_USER:%{HTTP:Authorization},L]


I install codeigniter and start to write some code on it.First i want to remove index.php and make some research about it.I remove it with a small htaccess code below,

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ /pasaj/index.php/$1 [L]

and then set my base_url in config.php as,

$config['base_url'] = 'http://localhost/pasaj/'; 

and then i decided to use base_url in form's actions

and wrote it like that(please look at action)

  <form method="post" id="formSubmit" name="fSubmit" action=<?php base_url(); ?>"kayit/kayitOnay/">

but it did not work

and prints url like that

what i did all is not working

and i suspect from my htaccess file.I removed it. i use it for removing index.php in codeigniter default.

and set my new base url like that necessarily

http://localhost/pasaj/index.php/

and do not change anything above form code

and it works.

Now, i want to still use this htaccess file in order to remove index.php but when htaccess file exists my base_url works wrongly . What might be the changes in htaccess file ?

解决方案

try this

RewriteEngine on
RewriteBase /pasaj/
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

My htaccess files on a local server looks like this:

For a Zend Framework web:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

For a CodeIgniter web:

RewriteEngine on
RewriteBase /pasaj/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]

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

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