我开发了一个CI网站,并托管在服务器根目录上,我还创建了一些静态html页面并将它们放在website
目录中。 (见下文)
public_html
/application
/other ci folder
/index.php
/.htaccess
/website // in this directory i have my static html website
所以,当我输入www.myweb.com
时,我可以访问我的CI应用程序,
CI申请有2条主要路线。
www.myweb.com for front end
www.myweb.com/admin backend
现在我可以使用访问静态html网站了
www.myweb.com/website
我想要的是:
当我进入
www.myweb.com
它应该显示静态html网站
www.myweb.com/app
它应该显示ci网站的前端
www.myweb.com/admin
它应该正常工作
我尝试的是:
我搜索了google / stack overflow并发现了一些 .htaccess 解决方案,
<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>
你能建议我解决方案。感谢
答案 0 :(得分:0)
我找到了一个问题的解决方案,我想分享所有
<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>
我将我的资产与codeigniter资产合并(更正了css和js的几条路径),因此它对我有用。
希望它适用于某人。
从这篇文章中获得帮助:.htaccess - When there is no requested URI