douweinu8562 2015-06-16 09:11
浏览 105
已采纳

连接两个.htaccess文件

On my site is currently running wordpress so my .htaccess looks like this:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

But I need to test other(laravel) application there. If I replace .htaccess with this:

RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

my laravel app works. Is there any way how to be able to keep working both apps? Specifically it would be good if second app runs just on some alias e.g. www.mysite.com/secreturl. I tried to combine it like so:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


RewriteRule ^secret(.*)$ public/$1 [L]

But I couldn't achieve anything. Thanks.

  • 写回答

1条回答 默认 最新

  • dth2331 2015-06-16 09:24
    关注

    You can't have both apps in the same directory, because they would both need index.php as the application entry point and that creates conflicts (also Laravel's public directory shouldn't be inside the document root, it should be the document root).

    You should serve the Laravel application (if that's of secondary importance) using a virtual host either in a subdirectory or a subdomain. Here's an example using a subdomain:

    <VirtualHost *:80>
        ServerName laravelapp.example.com
        DocumentRoot "/path/to/larvel/app/public"
    
        <Directory "/path/to/larvel/app/public">
            AllowOverride all
        </Directory>
    </VirtualHost>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错