此处将为大家介绍关于CodeIgniter的htaccess子文件夹问题的详细内容,并且为您解答有关.code文件的相关问题,此外,我们还将为您介绍关于.htaccess子文件夹、Access-Con
此处将为大家介绍关于CodeIgniter的htaccess子文件夹问题的详细内容,并且为您解答有关.code文件的相关问题,此外,我们还将为您介绍关于.htaccess子文件夹、Access-Control-Allow-Origin没有出现在来自codeigniter的响应标头中、apache+codeigniter 通过.htcaccess做动态二级域名解析、apache+codeigniter 通过.htcaccess做动态二级域名解析_php技巧的有用信息。
本文目录一览:- CodeIgniter的htaccess子文件夹问题(.code文件)
- .htaccess子文件夹
- Access-Control-Allow-Origin没有出现在来自codeigniter的响应标头中
- apache+codeigniter 通过.htcaccess做动态二级域名解析
- apache+codeigniter 通过.htcaccess做动态二级域名解析_php技巧
CodeIgniter的htaccess子文件夹问题(.code文件)
我想在我的域中的文件夹testing中的第二个网站
www.mydomian.com/test
在Linux上运行的Apache服务器。
但是,当我在我的导航器样式中加载它,图像,佣工无法find。
.htaccess文件没有被读取(“.htaccess文件中的选项 – 索引”不起作用)
.htaccess仅针对特定目录重写条件结尾斜杠
Apache重写没有mod_rewrite?
.htaccess将子域redirect到域
用.htaccess中选定的查询string参数重写URL
我的htaccess是这样的:
RewriteEngine On
RewriteBase /testing
RewriteCond %{REQUEST_URI} ^system.* RewriteCond $1 !^(index.PHP|images|robots.txt) RewriteCond %{REQUEST_URI} ^application.* RewriteRule ^(.*)$ /test/index.PHP?/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.PHP?/$1 [L]
先谢谢你
我已经尝试了你所说的,把你给我的htaccess文件放在testing文件夹中,另一个放在根目录中,它不起作用。
其他选项?
如何添加通配符子域redirect到htaccess中的子目录?
.htaccess使用GET参数redirect
从url去除参数,使一个友好的Url htaccess
如何在.htaccess文件中禁用某些媒体文件的Apache gzip压缩?
使用.htaccess将一个特定的IP地址redirect到我的主页的特殊页面
尝试将.htaccess文件添加到您的测试文件夹。
我使用这个.htaccess内容:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.PHP?/$1 [L]
在文件夹测试中,我会放置另一个.htaccess,几乎相同的内容:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /test/index.PHP?/$1 [L]
总结
以上是小编为你收集整理的CodeIgniter的htaccess子文件夹问题全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
.htaccess子文件夹
我有以下结构
-www -subfolder
在www我有我的主要网站的index.PHP 。
在子文件夹中,我有一个pipe理用户界面,在那里我想有另一个pipe理用户界面的index.PHP 。
目前我在/subfolder/index.PHP请求被redirect到www/index.PHP ,基本上我的pipe理界面的页面没有显示出来。
如何重新编写锚定cms的指令
http:// domain to https:// www in one redirect
.htaccess中的基本URL
Apache Web服务器不允许我刷新/关于本地主机,但它的工作正常
国防部重写子域到文件夹中断到CSS和图像的path
这是我的.htaccess文件:
RewriteEngine On RewriteRule ^$ index.PHP [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/(.*)$ index.PHP?lang=$1&page=$2 [L]
你可以帮我吗? 我已经在其他答案尝试了几个选项,但因为我没有这么先进的Web开发人员,我无法得到任何工作。
@TerryE,对不起,如果我是粗俗的。
我正在使用本地设置进行testing。 我已经安装了Vertrigo服务器,它给了我Apache服务器。在Windows7操作系统上运行。 服务器安装在Program files VertrigoServ Apache文件夹中。
我的公用文件夹是www。 在那里我有我的主要网站的定义。 。 该站点通过127.0.0.1/index.PHP或127.0.0.1/在本地访问
我有网站本地化,所以URL被构build为/$lang/$page例如<a href=" / <?PHP echo $lang; ?> / home "> HOME </a>
在主站点的index.PHP中我有以下几点:
$page = trim( ( isset( $_GET[ ''page'' ] ) ? $_GET[ ''page'' ] : ''home'' ),''/'' ); $lang = trim( ( isset( $_GET[ ''lang'' ] ) ? $_GET[ ''lang'' ] : ''en'' ),''/'' ); $langs = array( ''en'',''fr'',''ru'' );
根据这些数据,我可以这样打开页面:
include ''html/''. $lang . ''/'' . $page . ''.PHP'';
我所有的主要网页都位于www/html/$lang/
$_SERVER[''REQUEST_URI''])为页面HOME提供/en/home 。
127.0.0.1/en/home WORKS
所有的导航都适用于主站点。
不过,我已经创build了一个pipe理用户界面,位于文件夹www / admin – www下面的一个级别。
在那里我没有任何本地化。 我只是EN语言。 所以在pipe理文件夹中的index.PHP的顶部,我再次
$page = trim( ( isset( $_GET[ ''page'' ] ) ? $_GET[ ''page'' ] : ''home'' ),''/'' );
但是,这里的导航如下<a href=/admin/home"> HOME </a>
并在此之后我得到在admin文件夹的index.PHP中构build页面如下:
include ''html/ . $page . ''.PHP'';
该网页位于www/admin/html
这根本不起作用。 每当我按pipe理界面中的家庭链接,我被redirect到我的主站点(不存在的页面)。 如果我在.htaccess中添加RewriteRule ^subfolder/ - [L] ,我得到HTTP 404 NOT Found error 。
127.0.0.1/admin/home不起作用。 pipe理员内部没有任何其他导航。 感谢您的意愿和耐心帮助我!
.htaccess基于HTTP_REFERER的redirect是空的
在Windows服务器上运行的Apache是一个htaccess文件不同
wordpress htaccess如何删除除index.PHP之外的所有PHP扩展
如何在1and1共享主机上configurationCake 2.3.x的htaccess文件
根据apache envvariables,有条件地要求HTTPauthentication
我从这里假定你的www目录中只有一个.htaccess文件。
想想规则是什么
RewriteRule ^(.*)/(.*)$ index.PHP?lang=$1&page=$2 [L]
在从www的Perdir上下文中解释时,可以采用someDir someDir/somePage形式的任何URI并将其替换为index.PHP?lang=someDir&page=somePage ,这样就可以拦截并重写任何/subfolder/index.PHP 。
这没有很好的记录,但是Perdir处理将优先使用请求路径上最低的.htaccess文件设置RewriteEngine On 。 因此,如果您在“子文件夹”子文件夹中添加特定于管理员的.htaccess文件,则会抢占www并阻止此问题。
后记评论
当真正的问题是“如果我的网站是由一个共享服务托管的,我该如何调试我的.htaccess规则”,Veni和其他海报才能进行问答。 我添加共享服务限定的原因是,如果你有LAMP配置的root访问权限,那么你可以打开重写日志记录,并且在4-6的调试级别的日志文件将给你足够的取证来确定发生了什么。
然而,大多数爱好/小服务用户在共享的基础上购买他们的服务,在这里他们没有root访问权限,主机提供商为了性能原因禁用了这种日志记录,所以他们有一个二进制反馈 – 规则工作或他们别。 我使用共享服务,我的方法( 这里描述)是建立一个虚拟机镜像这个配置作为一个测试和集成环境 – 在这个我有这样的根访问。 但是,对于大多数用户来说这可能太复杂了。 这实际上是一个更广泛的话题,值得自己的Q /讨论。
具体问题:
如果你的结构是/(lang|admin)/page ,那么你为什么有这个规则,因为它会导致perdir重试。
RewriteRule ^$ index.PHP [QSA,L]
更好的方式如下,强制重定向到默认的语言(假设lang列表在本例中是EN和IT:
RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteCond $1 !^/(en|it|admin)/ RewriteRule ^(.*) http://yourdomain/en/$1 [R=301,L]
你知道重定向重启/循环的问题吗? (搜索REDIRECT_STATUS)
我是新来的Stackoverflow,但不是整理这种s **吨。 我在这个博客上有几篇详细的文章。
后记评论 – 还有更多
确定一些一般的帮助。
不要我们固定的IP把127.0.0.1的别名放在你的windows system32 drivers etc hosts中
您可以在VertrigoServ Apache配置文件中打开重写日志记录,这将为您提供详细的问题审核
如果你有一个诊断存根来帮助你理解发生了什么,这也是有帮助的,这就是我在测试目录中为index.PHP所提出的:
<?PHP header( "Content-type: text.plain" ); echo "main: "; var_export($_GET);
但是你真的需要以下每种情况: – 处理URI存在(并停止重写循环) – 默认值为/和/ admin / – admin / * – * / * – *(和语言默认值)
这就是我想出来的。 我保持简单。 我们可以使用复杂的正则表达式来折叠其中的一些,但为什么要麻烦。 如果需要,您可能需要添加更多的QSA。
RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule . - [L] RewriteRule ^$ index.PHP [QSA,L] RewriteRule ^admin/?$ admin/index.PHP [QSA,L] RewriteRule ^admin/(.*)$ admin/index.PHP?page=$1 [L] RewriteRule ^(.*)/(.*)$ index.PHP?lang=$1&page=$2 [L] RewriteRule ^(.*)$ index.PHP?lang=en&page=$1 [L]
RewriteEngine On RewriteRule ^$ index.PHP [QSA,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^subfolder/(.*)$ subfolder/index.PHP?page=$2 [L] RewriteRule ^(.*)/(.*)$ index.PHP?lang=$1&page=$2 [L]
您可以阻止对您的子文件夹的请求被改写为下面的更改
RewriteEngine On RewriteRule ^$ index.PHP [QSA,L] #prevent requests to your subfolder from being rewritten RewriteCond %{REQUEST_URI} !^/subfolder/ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/(.*)$ index.PHP?lang=$1&page=$2 [L]
总结
以上是小编为你收集整理的.htaccess子文件夹全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
Access-Control-Allow-Origin没有出现在来自codeigniter的响应标头中
我的Codeigniter文件说
$CI->output->set_header("Access-Control-Allow-Origin: *");$CI->output->set_header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");$CI->output->set_status_header(200);$CI->output->set_content_type(''application/json'');echo json_encode(array("city" => "dhaka"));
但是我得到的http响应是:
Request URL:http://localhost/index.php/location/cityRequest Method:POSTStatus Code:200 OKConnection:Keep-AliveContent-Length:16Content-Type:text/htmlDate:Sun, 22 Jul 2012 10:27:32 GMTKeep-Alive:timeout=5, max=100Server:Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.6X-Powered-By:PHP/5.3.6
Access-Control-Allow-Origin
即使包含,响应中仍缺少标题Access-Control-Expose-Headers:Access-Control-Allow-Origin
。我有关此标头的信息来源来自Mozilla开发人员网站
答案1
小编典典事实证明,仅当我通过PHP语法header()
而不是codeigniter语法设置标头时,它才对我有用$CI->output->set_header()
。真伤心
apache+codeigniter 通过.htcaccess做动态二级域名解析
. 代码如下:
AuthName "yousite Website Coming Soon..." //如果你想给你的网站加个权限访问
AuthType Basic
AuthUserFile D:/xxx/.htpasswd #如果你想设置密码访问 如何生成.htpasswd可以访问 http://www.htaccesstools.com/htpasswd-generator/
#AuthGroupFile /dev/null
require valid-user
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#''system'' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn''t in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename ''application'' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
# Redirect to boutique (with any trailing path)
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+).yousite.com(.*)$ [NC]
RewriteRule ^(.*)$ http://www.yousite.com/boutique/$1$2 [P,L]
# Redirect to boutique (with any trailing path)
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+).yousite.com(.*)$ [NC]
RewriteRule ^(.*)$ http://www.yousite.com/boutique/%1/$1 [R=301,L]
## Otherwise, force www;
RewriteCond %{HTTP_HOST} ^yousite.com$ [NC]
RewriteRule ^(.*)$ http://www.yousite.com/$1 [R=301,L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn''t true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
# If we don''t have mod_rewrite installed, all 404''s
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
以上就是apache+codeigniter 通过.htcaccess做动态二级域名解析的内容,更多相关文章请关注PHP中文网(www.php.cn)!
apache+codeigniter 通过.htcaccess做动态二级域名解析_php技巧
AuthName "yousite Website Coming Soon..." //如果你想给你的网站加个权限访问
AuthType Basic
AuthUserFile D:/xxx/.htpasswd #如果你想设置密码访问 如何生成.htpasswd可以访问 http://www.htaccesstools.com/htpasswd-generator/
#AuthGroupFile /dev/null
require valid-user
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#''system'' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn''t in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename ''application'' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
# Redirect to boutique (with any trailing path)
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+).yousite.com(.*)$ [NC]
RewriteRule ^(.*)$ http://www.yousite.com/boutique/$1$2 [P,L]
# Redirect to boutique (with any trailing path)
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+).yousite.com(.*)$ [NC]
RewriteRule ^(.*)$ http://www.yousite.com/boutique/%1/$1 [R=301,L]
## Otherwise, force www;
RewriteCond %{HTTP_HOST} ^yousite.com$ [NC]
RewriteRule ^(.*)$ http://www.yousite.com/$1 [R=301,L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn''t true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
# If we don''t have mod_rewrite installed, all 404''s
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
出处:cnblogs 微博:@草根小胡
今天的关于CodeIgniter的htaccess子文件夹问题和.code文件的分享已经结束,谢谢您的关注,如果想了解更多关于.htaccess子文件夹、Access-Control-Allow-Origin没有出现在来自codeigniter的响应标头中、apache+codeigniter 通过.htcaccess做动态二级域名解析、apache+codeigniter 通过.htcaccess做动态二级域名解析_php技巧的相关知识,请在本站进行查询。
本文标签: