I need to set up my Larave project inside another PHP project to access that project using https://example.com/laravel-project
Because I need to use the same domain for the new Laravel project.
For that, I used apache VirtualHost configuration like below,
<VirtualHost *:80>
ServerName example.com
DocumentRoot "C:/Wamp/vhosts/example"
Alias /laravel-project "C:/Wamp/vhosts/example/blog/laravel-project/public"
<Directory "C:/Wamp/vhosts/example">
allow from all
order allow,deny
AllowOverride All
</Directory>
</VirtualHost>
Now routes are working fine but query strings not working well. seems every url missing query strings.
https://example.com/laravel-project?test=value
But Laravel App didn't identify test query parameter.
How can I fix this problem?
The issue was not in VirtualHost configuration, It's in .htaccess file configurations. Updating RewriteRule with [QSA] flag, solved query string missing issue.
RewriteRule ^ index.php?$1 [L, QSA]
Related
I have a VPS running WHM and Cpanel. I have multiple domains hosted there. Say one of them is example.com
What I am intending to do is have two versions of the application.
Production: example.com > /public_html/
Development: staging.example.com > /public_html/staging/
Right now, I am trying to deploy my application to the development environment, i.e to the staging folder.
Envoyer, with a lot of struggle with my hosting provider, is working fine. It's uploading the files as expected. The only issue now is the symbolic link current
Right now the folder structure is:
-staging
- releases
-release1
-release2
- current
My subdomain clearly points out to the staging folder, which will lead it to display all the contents of the folder rather than the application.
Since the application is inside the release folder, how do I make sure that my application runs when we hit the subdomain.
Do I have to modify my virtual hosts file in Apache?
Laravel requires the root for the domain (configured in the relevant apache vhost conf file) to be it's 'public' folder. This is where it's entry point index.php is.
Edit the apache vhosts conf file as per below
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/home/user/public_html/public"
<Directory "/home/user/public_html/public">
Options Indexes FollowSymLinks
AllowOverride all
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName staging.example.com
DocumentRoot "/home/user/public_html/staging/public"
<Directory "/home/user/public_html/staging/public">
Options Indexes FollowSymLinks
AllowOverride all
Allow from all
Require all granted
</Directory>
</VirtualHost>
For example.com you install your laravel application into /home/user/public_html folder.
As part of the laravel install it will create the 'public' folder.
For staging.example.com you install your laravel application into /home/user/public_html/staging folder.
Don't forget to restart the web server so it picks up the new configuration.
If you do not have the ability to change the vhost configuration mentioned above, you can use .htaccess file in your public_html folder (note the leading full stop which makes it a hidden file). The following is dependant on your hosting provider allowing .htaccess overrides.
Add the following to the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
If domain has been set up correctly by the host to point to /home/username/public_html when entering http://example.com then it should automatically call public/index.php.
You will need to do the same in public_html/staging folder.
I'm trying to build a web app in laravel 5.2 on windows platform with wamp server installation.
I'm trying to call a dashboard page by following routes:
Route::get('nitsadmin/dashboard', function () {
return view('nitsadmin.dashboard');
});
Following is the route list:
where my file structure is as below:
My virtual host configuration in httd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "c:\wamp\www\nitsedit\public"
ServerName nitseditor.dev
</VirtualHost>
Apache alias:
Alias /nitseditor.dev "C:/wamp/www/NitsEdit/public"
<Directory "C:/wamp/www/NitsEdit/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
Don't know where I'm getting problem but I'm getting following error:
You have wrong web server configuration, just point web server to a public directory in Lararel project root and restart web server.
You're using the wrong URL, ditch the "nitsedit\public" part:
http://nitseditor.dev/nitsadmin/dashboard
Apache is already pointing the user to the public folder.
Just commented out Include conf/extra/httpd-vhosts.conf in the file httpd.conf present in folder wamp/bin/apache/apache2.4.9/conf and it worked.
I've set up wamp and laravel with composer, and virtualhosts too. Whenever I go to my project folder 'localhost/project/', or my vhost 'project.dev', I only see the file directory of the laravel project. Yet if I go to 'project.dev/public' or 'project.dev/server.php' it works. What am I doing wrong?
You need to set your DocumentRoot (in your vhosts file) to C:\location\of\laravel\public instead of C:\location\of\laravel\
Here is an example, dont forget to also tell Apache from where it is allowed to accespt connections as well.
<VirtualHost *:80>
DocumentRoot "D:/wamp/www/laravel/public"
ServerName laravel.dev
Options Indexes FollowSymLinks
<Directory "D:/wamp/www/laravel/public">
AllowOverride all
Require local
Require ip 192.168.1
</Directory>
</VirtualHost>
I am trying to create a virtual host for a Zend Framework project, but it is not working.
I added the string "127.0.0.1 mysite.local" to the hosts file (/private/etc/hosts), and this is what I put in httpd.conf:
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "/Applications/MAMP/htdocs/mysite/public"
SetEnv APPLICATION_ENV "development"
<Directory "/Applications/MAMP/htdocs/mysite/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I restarted server, and then I try to access it in browser like: http://mysite.local:8888/, but it takes me to "htdocs" root, not to the Zend Project.
Am I missing something? Did I type something wrong? I'm using MacOSX, I tried putting port 8888 instead of 80 in the VirtualHost definition but it didn't work too.
Thanks
I'm encountering a problem with my cakephp app...
I'm using Cakephp 2.4.3 with XAMPP on MacOSX Mavericks and I'm getting the message : URL rewriting is not properly configured on your server. 1) Help me configure it 2) I don't / can't use URL rewriting
But I configured the sites according to the url rewriting tutorial...
I have a Virtualhost :
<VirtualHost 127.0.0.1>
ServerName cake84.loc
DocumentRoot "/Users/me/Sites/c84/cakephp"
DirectoryIndex index.php
<Directory "/Users/me/Sites/c84/cakephp">
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
with ref in hosts file : 127.0.0.1 cake84.loc
the .htaccess file is present and contains:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
and I have the file /Application/XAMPP/etc/httpd.conf with the line :
LoadModule rewrite_module modules/mod_rewrite.so uncommented...
Am I forgetting something ?!!
Notice that the same configuration was working a week ago but in the parent folder. The only change I've made was to move the whole site from : /Users/me/Sites/c84 to /Users/me/Sites/c84/cakephp and then changing the path of the virtualhost. (And for sure, restarted the apache...)
Well... Problem solved...
It seems that cakephp has problems to detect correctly if the rewrite url mode is enabled...
The best way is to call an url that should be rewritten to test the url rewritting.
In my case, the url rewriting was correctly enabled although I got this message... But unfortunately, the url I called to test it, had a syntax error (typo...) that I missed and nothing was shown...
I am also on Mavericks. For me, I had to edit the file:
/private/etc/apache2/users/myusername.conf
(Replace myusername.conf with the username on your computer.)
In this file, I had to change the lines:
Options Indexes MultiViews to Options Indexes MultiViews FollowSymLinks
and
AllowOverride None to AllowOverride All,
and then restarting Apache, solved the problem.
Hope this helps anyone else Googling for a solution on Mavericks.