[英].htaccess is not working on cpanel
這是我的localhost:8080
.htaccess
,它工作正常。
# 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文件,其中顯示了以下鏈接
# 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>
我現在能做什么?
重寫基礎不需要您的URL,因為我想您是從public_html訪問它的。 將其更改為RewriteBase /
在本地主機上,它將起作用:
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]
它為我工作。 我認為這會幫助其他人。
您在以下行中出錯:
RewriteBase /www.sunrisecoachingcenter.com/
嘗試刪除它,因為它可能會導致您的網站出錯。
RewriteBase
僅用於修復.htaccess
不在網站根目錄下的情況,並且它猜測正在運行的文件夾的Web路徑錯誤。因此,如果文件夾中的.htaccess
可以通過http://example.com/sunrise/
訪問, http://example.com/sunrise/
您可以使用:
RewriteBase sunrise
在您的本地主機上-是正確的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.