2014-04-27 79 views
1

这是我的.htaccesslocalhost:8080这是正常工作。.htaccess不能在cPanel上工作

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

这是我www.sunrisecoachingcenter.com的.htaccess这显示出下面的link

# 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 /www.sunrisecoachingcenter.com/ 

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

现在我该怎么办?

+0

尝试删除RewriteBase :) –

+0

抱歉给您带来不便。刚刚得到解决方案。需要使用'RewriteCond%{HTTP_HOST}^www \ .sunrisecoachingcenter \ .com $ [NC]'和'RewriteRule ^(。*)$ http://sunrisecoachingcenter.com/$1 [L, R = 301]'但不是'RewriteBase/www.sunrisecoachingcenter.com /'。不管怎么说,还是要谢谢你。 – Sujit

回答

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] 

它为我工作。我认为这会帮助其他人。

0

你有错误与以下行:

RewriteBase /www.sunrisecoachingcenter.com/ 

尝试去掉这个,因为它可能与你的网站产生错误。

RewriteBase只用于解决地方.htaccess在一个站点的根目录没有放置的情况下,并猜测它在运行文件夹中的错误的网络路径。因此,如果你有一个文件夹中.htaccess可访问在http://example.com/sunrise/您可以使用:

RewriteBase sunrise 

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

+0

使用'RewriteBase'时,重写的URI是前缀*,如果是相对的(解析为,如果在文档根目录中则不需要)。如果给定的值是错误的,并且重写的URI相对(原样),则URI已被重写为不存在的URI(404)。 – hakre

1

重写库不需要你的URL,因为我认为你正在从public_html访问它。 将其更改为 RewriteBase/