设置
'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
似乎规则正在起作用但是方式错误
im so noob with mod reritex in mod rewrite files:(
继承我的整个文件
#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>
答案 0 :(得分:0)
确保godpanel规则超越所有其他规则。
其次尝试从规则^/godpanel
部分的开头删除正斜杠:
RewriteRule ^godpanel$ /panel/godpanel [R=301,L]