这是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访问它的。将其更改为重写Base/
在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]
它对我有效。我想它会帮助其他人。
您在以下行出现错误:
RewriteBase /www.sunrisecoachingcenter.com/
请尝试删除此项,因为它可能会在您的网站上产生错误。
RewriteBase
仅用于修复以下情况:.htaccess
不在站点的根目录中,并且它猜测其运行的文件夹的web路径错误。因此,如果您在可以在http://example.com/sunrise/
访问的文件夹中有.htaccess
,则可以使用:
RewriteBase sunrise
在本地主机上,这是正确的。