我正在使用Codeigniter并尝试让我的URL重写在我的公共服务器和本地服务器上运行。
当我在公共服务器上时,我项目根目录中的.htaccess
文件需要如下所示:
RewriteEngine On
RewriteBase /sesamo/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
但是当我在公共服务器上时,它需要看起来像这样:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{HTTP_HOST} ^sesamorepair.com [NC]
RewriteRule ^(.*)$ http://www.sesamorepair.com/$1 [L,R=301]
如何创建一个简单的.htaccess
文件,从本地和公共环境中成功删除url中的index.php?
我确实试过把它们放在一起就像这样:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{HTTP_HOST} ^sesamorepair.com [NC]
RewriteRule ^(.*)$ http://www.sesamorepair.com/$1 [L,R=301]
RewriteBase /sesamo/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
这在我的本地服务器上运行但在我的公共服务器上给了我一个内部服务器错误。有什么建议吗?