简体   繁体   中英

apache htaccess redirect app root to non-existant sub directory

I have a lamp stack app that is deployed to example.com/directory/ for production. The production environment redirects traffic to /directory/ and the app is served directly from that location.

When developing locally I would like to replicate this by serving files which live my apps root folder at

localhost:33309/directory/

instead of

localhost:33309

in my apps root .htaccess file I have tried a number of things. The example below does an ok job for redirecting traffic but how do I make that path serve content that does not live in /directory/?

RewriteEngine on
# route to directory from app root
RedirectMatch ^/$ /directory/

I don't want to create the /directory folder locally I just want to make my localhost appear like it is serving the app at a path of a non existent directory.

Wondering if I need to do something with VirtualHosts or if this is possible to configure?

Try with below rule,

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/directory/(.*)$
RewriteRule ^ /%1 [L]

我认为您想要别名:别名“ / directory /”“ /”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM