How to prevent users from navigating to symfony project directories? - symfony

How to prevent users from navigating to symfony project directories?
I see vendor directory content when I visit:
http://localhost/myproject/vendor/

You should configure your web server's document root directory to /web folder to avoid this issue. Sample configuration snippet for Apache:
DocumentRoot /var/www/project/web
<Directory /var/www/project/web>
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>

Related

non www to www not working for wordpress in EC2 instance using safari

If I use my safari browser, I cannot get to my website example.com. I have to use www.example.com for it to work. I tried editing htaccess numerous times and still, it doesn't work.My website is using bitami wordpress image (https://docs.bitnami.com/)which is hosted in AWS.
Bitnami Engineer here:
By default, we disable .htaccess files due to security and performance reasons. We also move .htaccess files content to a file called htaccess.conf in the folder /opt/bitnami/apps/wordpress/conf. You can check more about it at https://docs.bitnami.com/aws/infrastructure/lamp/administration/use-htaccess/.
If you want to enable .htaccess usage, you would need to set it to AllowOverride All in /opt/bitnami/apache2/conf/bitnami/bitnami.conf file:
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache2/htdocs"
<Directory "/opt/bitnami/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All <---- HERE
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3 >
Require all granted
</IfVersion>
</Directory>
And restart Apache after applying your changes.
For more info, find WordPress documentation below:
https://docs.bitnami.com/aws/apps/wordpress/
Regards

How to set Symfony3 environment in Apache

I am running Apache 2.4 on my development machine so I can test code locally. How do I tell Symfony 3.4 to use the 'dev' environment instead of the 'prod' environment?
I've tried browsing to http://localhost/app_dev.php but that just redirects to http://localhost/. It looks like the front controller is set in .htaccess but if I modify that file, then my production server will be using the wrong front controller.
I've read the docs on the following pages and it talks about how to create new environments but not how to set the default environment.
https://symfony.com/doc/3.4/configuration/environments.html
https://symfony.com/doc/3.4/setup/web_server_configuration.html
I'm running Apache 2.4 on Windows 10 and here is my vhost configuration
<VirtualHost *:80>
ServerName example.local
DocumentRoot "C:\Users\kento\PhpstormProjects\example\web"
<Directory "C:\Users\kento\PhpstormProjects\example\web">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex app_dev.php
</Directory>
ErrorLog "logs/example-error.log"
CustomLog "logs/example-access.log" common
</VirtualHost>
example.local points to 127.0.0.1 in my hosts file. I set DirectoryIndex to app_dev.php but that seems to be overridden by the .htaccess file.
You've already set the vhost to use app_dev.php, but then you allow a .htaccess to override with the AllowOverride All. Change that to AllowOverride None and the .htaccess will be ignored.
There may be some config from there you would be able to merge into the vhost.
I tend to prefer all the configuration in the virtual host, and not have any use of a .htaccess file, for a small speed boost - especially in production.

images and css not displaying in Symfony on Xampp Server

I have downloaded the Symfony project and added the database.
But when I am going to web folder then on the home page. Images and CSS not displaying.
It is showing like below,
http://localhost/uploads/logos/image.jpg
** but my project is on a folder name like /folder/ **
All the images and css have broken links.
How did you run the web server? Try this,
Symfony v2.* = php app/console s:r
Symfony v3.* = php bin/console s:r
If you want to Xampp Server, you should change the root directory;
project_directory/web
In this matter virtual host is the best solution.
<VirtualHost *:80>
ServerName project.local
ServerAlias www.project.local
DocumentRoot "C:\xampp\htdocs\project\web"
<Directory "C:\xampp\htdocs\project\web">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Allow from All
</Directory>
</VirtualHost>

change default folder for apache

I have installed a Wordpress instance using Bitnami.
Currently 127.0.0.1 takes my to the file in the C:\Bitnami\wordpress-4.4.2-1\apache2\htdocs
I want 127.0.0.1 to take the user to C:/Bitnami/wordpress-4.4.2-1/apps/wordpress/htdocs
Changes i have done:
Edit the httpd.conf file
DocumentRoot "C:/Bitnami/wordpress-4.4.2-1/apps/wordpress/htdocs"
<Directory "C:/Bitnami/wordpress-4.4.2-1/apps/wordpress/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Require all granted
allow from all
</Directory>
Restarted apache server
Still going to 127.0.0.1 shows the index.php page under C:\Bitnami\wordpress-4.4.2-1\apache2\htdocs
What am i missing?
I don't know about Windows, but on my Ubuntu system, I also had to change document root in the sites-enabled/000-default.conf file. Just make sure all configuration files are updated correctly to point to your new document root.
Hope this helps!

Trying to install asp.net on xampp

im trying to run aspx files on my xampp installation But the Apache Server doesn't Start.
What i did:
Installed a clean Xampp.
Installted the mod_aspdotnet-2.2.0.2006-setup-r2.msi
changed my httpd.conf:
#asp.net
LoadModule aspdotnet_module modules/mod_aspdotnet.so
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj licx rem resources resx soap vb vbproj vsdisco webinfo
<IfModule mod_aspdotnet.cpp>
AspNetMount /SampleASP "C:\xamppASP\htdocs"
Alias /SampleASP "C:\xamppASP\htdocs"
<Directory "C:\xamppASP\htdocs">
Options FollowSymlinks ExecCGI
Order allow,deny
Allow from all
DirectoryIndex index.htm index.aspx
</Directory>
AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
<Directory "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
Options FollowSymlinks
Order allow,deny
Allow from all
</Directory>
</IfModule>
#asp.net
After this steps the Server doesn't start anymore.
Even if i just run:
LoadModule aspdotnet_module modules/mod_aspdotnet.so
The Server doesn't start.
I already checked the Folder C:\xamppASP\apache\modules
The file exists.
What am i doing wrong?
Im pretty sure that this:
AspNetMount /SampleASP "C:\xamppASP\htdocs"
Alias /SampleASP "C:\xamppASP\htdocs"
<Directory "C:\xamppASP\htdocs">
Should be:
AspNetMount /SampleASP "C:\xamppASP\SampleASP"
Alias /SampleASP "C:\xamppASP\SampleASP"
<Directory "C:\xamppASP\SampleASP">
That is, that you change your directory name to the one you give as 'SampleASP'.
The reason it won't start anymore is probably because the directory you set doesn't exist.
"C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles"
I have been trying to get the same thing to work and I found that I don't have ASP.NETClientFiles, if you remove your changes it will start again.
Or if you figure out where ASP.NETClientFIles comes from and install that. Then it will work.

Resources