Apache Redirect in htaccess to subdirectory

前端 未结 1 1829
礼貌的吻别
礼貌的吻别 2021-01-23 09:15

I\'ve built an in house app that needs to start in public folder, directory structure is as follows

myapp/conf
myapp/tmp
myapp/doc
myapp/public
myapp/public/css
         


        
相关标签:
1条回答
  • 2021-01-23 09:57

    Try

    RewriteEngine On
    RewriteBase /myapp/
    
    RewriteCond %{REQUEST_URI} !/public/
    RewriteRule (.*) public/index.php/$1 [R=301,L]
    RewriteRule ^$ public [L]
    

    The main thing is you need to change the base to your app name. Then the rules can remain the same. The condition is needed to prevent redirect looping. But you probably won't need it if you have an .htaccess file handling requests inside /public/.

    0 讨论(0)
提交回复
热议问题