I've developed a CI website, and hosted on server root directory, I also created some static html page and put them in website
directory. (See below)
public_html
/application
/other ci folder
/index.php
/.htaccess
/website // in this directory i have my static html website
So when i enter www.myweb.com
i can access my CI application, CI application have 2 main routes.
www.myweb.com for front end
www.myweb.com/admin backend
and right now I'm able to access static html site using www.myweb.com/website
what i want is:
When i enter
www.myweb.com
it should show static html website
www.myweb.com/app
it should show front end of ci website
www.myweb.com/admin
it should work as it is working now
what i've tried is:
I searched on google/stack overflow and found some .htaccess solutions,
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?myweb\.com$ [NC]
RewriteRule !^website/ /website%{REQUEST_URI} [L,NC]
#above line works good and show website from website folder
RewriteCond %{HTTP_HOST} ^(www\.)?myweb\.com$ [NC]
RewriteRule (.*)/ %{REQUEST_URI} [L,NC]
#when i add these two line website shows 500 internal server error
#Other CI htaccess code to remove index.php
</IfModule>
Can you suggest me solutions. thanks
I found a solution to my question, I want to share it will all
<IfModule mod_rewrite.c>
RewriteEngine On
# If the requested URI is empty...
RewriteCond %{REQUEST_URI} !^$
# ...then redirect to the "website" folder
^/?$ /website/ [L] //or[L,R] if you want to redirect
# Otherwise rewrite the base
RewriteBase /
# If the request is not a folder or a file, redirects to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I merged my assets with codeigniter assets (Corrected few paths of css and js) so it worked for me.
Hope it will work for someone.
Took help from this post: .htaccess - When there is no requested URI
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.