macinville
macinville

Reputation: 236

Mod Rewrite to Localhost

I have a laravel application and I want the public folder to be accessible thru apache mod_rewrite. What should be my RewriteRule if I want my URL http://localhost/dev/admin to access http://localhost/dev/public/admin?

Upvotes: 0

Views: 119

Answers (1)

Ultimater
Ultimater

Reputation: 4738

I believe you're looking for something like this:

/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/$1 [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

Upvotes: 1

Related Questions