I have a new Project in Lumen which needs to be deployed to the Staging server and i have done it. I am facing issues with removing the names of directories from the URL. My project Directory is like this:
DIR - ProjectName
DIR - ProjectName {Lumen files inside this directory}
DIR - app
DIR - bootstrap
DIR - database
DIR - public
DIR - resources
DIR - storage
DIR - tests
DIR - Vendor
so currently to view my application i need to enter a url like this :
http://stagingserverdomain.com/ProjectName/ProjectName/public/login
However i would like my url to be like this:
http://stagingserverdomain.com/ProjectName/login
I have tried the many answers form SO but it does not work.
Use this:
RewriteEngine On
RewriteRule ^Projectname/login$ /ProjectName/ProjectName/public/login [L]
It should leave you with the following URL:
http://stagingserverdomain.com/ProjectName/login
Great question! Add this Apache httpd
RewriteRule
to the appropriate server definition inside your httpd.conf
file:
RewriteEngine On
RewriteRule ^/(ProjectName)/((?!\1).*) /$1/$1/public/$2
Alternatively, add this to a .htaccess
file at the root of your web-server, eg, where the first ProjectName
directory is located:
RewriteEngine On
RewriteRule ^(ProjectName)/((?!\1).*) $1/$1/public/$2
Alternatively, add this to a .htaccess
file within the first ProjectName
directory (where the second ProjectName
directory is located):
RewriteEngine On
RewriteRule ^((?!ProjectName).*) ProjectName/public/$1
Alternatively (and this is the recommended course of action), switch to nginx
, and do this:
location /ProjectName {
rewrite ^/([^/]+)/((?!\1).*)$ /$1/$1/public/$2;
}
The above code ensures that the rewrite
will only happen if your URLs don't already contain ProjectName/ProjectName
(using the lookahead assertions of PCRE , which is the library both NGINX and Apache use for support of the regular expressions ), so, there won't be any infinite redirect loops.
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.