Mod-Rewrite loading files behind the DocumentRoot

前端 未结 3 917
借酒劲吻你
借酒劲吻你 2021-01-04 07:10

I\'m using .htaccess and mod_rewrite to point to files that reside behind the DocumentRoot. My folder structure looks like this:

ho         


        
3条回答
  •  渐次进展
    2021-01-04 07:54

    The credit goes to Ryan Aheam, but I'm going to spell it out. I'm a beginner and even with Ryan's answer I had to experiment with a few things to get the syntax right.

    I wanted my DocumentRoot to be my cakephp directory. But then I had a Mantis Bug tracker that was just regular PHP and so not in the cakephp directory. The the files below I have the following working.

    http://www.example.com : served by /var/www/cakephp

    http://www.example.com/mantisbt : served by /var/www/html/mantisbt

    File /etc/httpd/conf/httpd.conf

    Alias /mantisbt/ "/var/www/html/mantisbt/"                                                                          
                                                                                            
        AllowOverride All                                                                                               
                                                                                                            
                                                                                                                        
                                                                                                      
        ServerAdmin me@my_email.com                                                                             
        DocumentRoot /var/www/cakephp                                                                                   
        ServerName my_website.com                                                                                      
                                                                                           
            AllowOverride All                                                                                           
                                                                                                            
    
    

    File /var/www/cakephp/.htaccess

    
        RewriteEngine on
        RewriteRule    ^mantisbt/?$   /mantisbt/  [NC,L]
        RewriteRule    ^$    webroot/    [L]
        RewriteRule    (.*) webroot/$1    [L]
    
    

提交回复
热议问题