Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 代码点火器中的mod_重写问题_Php_Codeigniter_Mod Rewrite_Url Rewriting_Backend - Fatal编程技术网

Php 代码点火器中的mod_重写问题

Php 代码点火器中的mod_重写问题,php,codeigniter,mod-rewrite,url-rewriting,backend,Php,Codeigniter,Mod Rewrite,Url Rewriting,Backend,背景 'RewriteBase /' 在生产现场和 'RewriteBase /mysitefolder' 在开发网站上解决了这个问题,希望这能帮助其他人 我对modRewrite和Codeigniter有一个大问题,我有以下重写规则: ### GO TO GODPANEL RewriteRule ^/godpanel$ /panel/godpanel [L] 我无法让此规则以这种方式重写我的页面: myhosting.com/godpanel 到 myhosting.com/pane

背景

'RewriteBase /'
在生产现场和

'RewriteBase /mysitefolder'
在开发网站上解决了这个问题,希望这能帮助其他人


我对modRewrite和Codeigniter有一个大问题,我有以下重写规则:

### GO TO GODPANEL

RewriteRule ^/godpanel$ /panel/godpanel [L]
我无法让此规则以这种方式重写我的页面:

myhosting.com/godpanel

myhosting.com/panel/godpanel

它一直说这个页面不存在。我不能制定其他规则来正常工作, 唯一有效的规则是重写
index.php

# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(start(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
希望你能理解我。谢谢

(编辑)

从昨天开始有些变化,
当我指向localhost/mysite.com/mycontroller时,它可以工作, 现在当我打开localhost/mysite.com/godpanel url更改为localhost/panel/godpanel

似乎规则是适用的,但在一个错误的方式

在mod rewrite文件中使用regexp的im so noob:(

这是我的全部档案

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

<IfModule mod_rewrite.c>

    RewriteEngine On

    ### GO TO GODPANEL

    RewriteRule ^godpanel$ /weird/stuff [R=301,L]

    ### Canonicalize codeigniter URLs

    # If your default controller is something other than
    # "welcome" you should probably change this
    RewriteRule ^(start(/index)?|index(\.php)?)/?$ / [L,R=301]
    RewriteRule ^(.*)/index/?$ $1 [L,R=301]

    # Removes trailing slashes (prevents SEO duplicate content issues)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ $1 [L,R=301]

    ###

    # 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]

</IfModule>

<IfModule !mod_rewrite.c>

    # Without mod_rewrite, route 404's to the front controller
    ErrorDocument 404 /index.php

</IfModule>
#重新启动引擎
#重写COND$1!^(index\.php | public | robots\.txt)
#重写cond%{REQUEST_FILENAME}!-f
#重写cond%{REQUEST_FILENAME}!-d
#重写规则^(.*)$index.php/$1[L,QSA]
重新启动发动机
###转到GODPANEL
重写规则^godpanel$/wird/stuff[R=301,L]
###规范化codeigniter URL
#如果您的默认控制器不是
#“欢迎”您可能应该更改此选项
重写规则^(开始(/index)|索引(\.php)/?$/[L,R=301]
重写规则^(.*)/索引/?$$1[L,R=301]
#删除尾部斜杠(防止SEO重复内容问题)
重写cond%{REQUEST_FILENAME}!-d
重写规则^(+)/$$1[L,R=301]
###
#检查用户是否试图访问有效文件,
#例如图像或css文档,如果这不是真的,它会发送
#请求index.php
重写cond%{REQUEST_FILENAME}!-f
重写cond%{REQUEST_FILENAME}!-d
重写规则^(.*)$index.php/$1[L]
#在没有mod_重写的情况下,将404路由到前控制器
ErrorDocument 404/index.php

确保godpanel规则高于所有其他规则

其次,尝试删除规则中
^/godpanel
部分开头的正斜杠:

RewriteRule ^godpanel$ /panel/godpanel [R=301,L]

godpanel规则是否放在index.php规则之上?是的,你可以在标题中将问题标记为已解决,但这不是StackOverflow的预期方式。如果你的问题已通过答案解决,请将该答案标记为“已接受”(除答案外还有复选标记)或者如果你自己找到了一个解决方案,考虑用你的解决方案发布一个答案(并标记为接受)。,这样您的解决方案也可以帮助其他用户。当我指向localhost/mysite.com/mycontroller时,它可以工作,现在当我指向localhost/mysite.com/godpanel时,url会更改为localhost/panel/godpanel,但工作方式不对等等……您的url是
localhost/mysite.com/mycontroller
?是的,我解决了问题,您必须在我的生产站点中将RewriteBase指定为“/”,在我的开发中指定为“/mysitefolder”。无论如何,感谢大家,您帮助我注意到了我的错误。