Here is my .htaccess
for localhost:8080
which is working fine.
# 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>
And this is my .htaccess for www.sunrisecoachingcenter.com
which is showing the following 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>
What can I do now?
The rewrite base doesn't need your URL as I presume you are accessing it from public_html. Change it to RewriteBase /
On localhost this will work:
RewriteEngine on
RewriteBase /rectangle/
But whenever we are in live server we must use this
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.sunrisecoachingcenter\.com$ [NC]
RewriteRule ^(.*)$ http://sunrisecoachingcenter.com/$1 [L,R=301]
or
RewriteEngine on
RewriteCond %{HTTP_HOST} ^sunrisecoachingcenter\.com$ [NC]
RewriteRule ^(.*)$ http://www.sunrisecoachingcenter.com/$1 [L,R=301]
It worked for me. I think it will help the others.
You have error with the following line:
RewriteBase /www.sunrisecoachingcenter.com/
Try removing this as it may produce errors with your website.
RewriteBase
is only used to fix cases where .htaccess
is placed not at the root of a site and it guesses the wrong web path for the folder it is running in. So if you have a .htaccess
in a folder that can be accessed at http://example.com/sunrise/
you can use:
RewriteBase sunrise
On your localhost - it's correct.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.