I would like to set up Polr Project , which is essentially a self-hosted URL shortener, on my hosting. In the installation guide it says that I need to set up a virtual host in httpd-vhosts.conf
. I don't have access to that file so I've got no idea on how to get it to work. I have seen some blog posts about how to do something like this but it doesn't seem to help.
Virtual Host Snippet:
<VirtualHost *:80>
ServerName example.com
ServerAlias example.com
DocumentRoot "/var/www/polr/public"
<Directory "/var/www/polr/public">
Require all granted
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I have tried this (but it failed):
RewriteCond %{HTTP_HOST} MY_DOMAIN.com
RewriteCond %{REQUEST_URI} !^/public
RewriteRule ^(.*)$ public/$1 [L]
Thanks in advance.
You cannot setup a virtual host in .htaccess, as can be seen from the <VirtualHost>
directive
Context: server config
But there's also no need to setup a virtual host, since your web hosting provider already did so.
You need only to install Polr in the document root as described and you're done.
The rewrite rule can be simplified to
RewriteRule !^public$ /public%{REQUEST_URI} [L]
If you have installed it in some subdirectory, eg polr
, the rule would be
RewriteRule !^polr/public$ /polr/public%{REQUEST_URI} [L]
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.