.htaccess没有在cpanel上工作

时间:2014-04-27 08:35:08

标签: php apache .htaccess codeigniter

以下是我.htaccess的{​​{1}}工作正常。

localhost:8080

这是# Deny OR Allow Folder Indexes. # Since we disable access to PHP files you # can leave this on without worries. # OR better yet, create a .htaccess file in # the dir you want to allow browsing and # set it to +Indexes Options -Indexes Options +FollowSymLinks # Set the default file for indexes DirectoryIndex index.php <IfModule mod_rewrite.c> # mod_rewrite rules RewriteEngine on # The RewriteBase of the system (if you are using this sytem in a sub-folder). RewriteBase /rectangle/ # If the file is NOT the index.php file RewriteCond %{REQUEST_FILENAME} !index.php # Hide all PHP files so none can be accessed by HTTP RewriteRule (.*)\.php$ index.php/$1 # If the file/dir is NOT real go to index RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L] </IfModule> # If Mod_ewrite is NOT installed go to index.php <IfModule !mod_rewrite.c> ErrorDocument 404 index.php </IfModule> 我的.htaccess,显示以下link

www.sunrisecoachingcenter.com

我现在能做什么?

3 个答案:

答案 0 :(得分:1)

重写基础不需要您的URL,因为我认为您是从public_html访问它。 将其更改为     RewriteBase /

答案 1 :(得分:1)

在localhost上,这将起作用:

RewriteEngine on
RewriteBase /rectangle/

但是无论何时我们都在现场服务器,我们必须使用这个

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.sunrisecoachingcenter\.com$ [NC]
RewriteRule ^(.*)$ http://sunrisecoachingcenter.com/$1 [L,R=301]

  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^sunrisecoachingcenter\.com$ [NC]
  RewriteRule ^(.*)$ http://www.sunrisecoachingcenter.com/$1 [L,R=301]

它对我有用。我认为这将有助于其他人。

答案 2 :(得分:0)

您遇到以下错误:

RewriteBase /www.sunrisecoachingcenter.com/

尝试删除此内容,因为它可能会导致您的网站出错。

RewriteBase仅用于修复.htaccess不在站点根目录的情况,并且它猜测正在运行的文件夹的错误Web路径。所以如果你有{ {1}}在.htaccess可以访问的文件夹中,您可以使用:

http://example.com/sunrise/

在您的本地主机上 - 它是正确的。