Mod 重写为本地主机

Mod Rewrite to Localhost

我有一个 laravel 应用程序,我希望可以通过 apache mod_rewrite 访问 public 文件夹。如果我想要 URL http://localhost/dev/admin to access http://localhost/dev/public/admin,我的 RewriteRule 应该是什么?

我相信您正在寻找这样的东西:

/dev/.htaccess

    RewriteEngine on

    #Because we're inside of a subdirectory
    RewriteBase /dev/

    #Handle the case of localhost/dev
    RewriteRule  ^$ public/    [L]

    #Handle the case of localhost/dev/...
    RewriteRule  ((?s).*) public/ [L]

    #The (?s) part is a Perl-style inline regex modifier meaning "single line"
    #so the dot will match unlikely new line characters.
    #I borrowed the idea from here:
    #https://docs.phalconphp.com/en/latest/reference/tutorial.html#beautiful-urls