环境
'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 重写文件中使用正则表达式的我很菜鸟 :(
这是我的整个文件
#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>