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 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题