I'm building my first Symfony site that will eventually be hosted on a shared server/cPanel site.
I'd like to have my Symfony/web content separate from the server files, though the way Symfony is structured, all the Symfony files are outside the public_html folder. But with a cPanel setup, there's already a lot of files and folders outside the public_html folder (mail, logs, .bashrc, .cpanel, www alias... and a dozen others).
I worry that it feels messy if I put Symfony mixed in with all these files and there could be a conflict. I would rather it be in a directory by itself. The best idea I've had so far is to make a subdomain to host Symfony where I can manually choose the web folder, and then just do redirects to the subdomain.
What do others do?
This is how I decided to do it, and it seems like it will work pretty well. I just use the regular cPanel public_html as the document root, upload the whole Symfony contents to that directory, but then add an .htaccess file with the contents:
RewriteEngine on
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]
And that protects the main Symfony contents from public access while at the same time putting it all in a directory by itself. It seems to work so far. If anyone has a better idea, I'm open to it!
Related
I am in the process of migrating my site to Wordpress from IIS.
I have run into an issue:
I have URL's that are a mix of upper and lower case that reference images. These URL's are getting a 404 because the case of the URL does not match the case of the file location.
For example, in my article I have a URL:
https://aaa.bbb.com/wp-content/migrate/ABC/abc.png
The file this is referencing is: /var/www/aaa/wp-content/migrate/abc/abc.png
When I change the URL to the same case as the file, it works, however how can I make it ignore the case of the folder on disk?
I tired the mod_speling module by putting this into /etc/apache2/apache2.conf but this just does not work for me. Also tried putting this into .htaccess in the root of my web directory but that made no difference.
<IfModule mod_speling.c>
CheckSpelling On
CheckCaseOnly On
</IfModule>
I have read various threads on here but I'm completely stuck.
I managed to find a work around to this.
I ended up writing a rewrite rule in the VirtualHost file to rewrite everything to lowercase apart from anything within the directory of assets imported from Windows.
I have a wordpress website with the integration of a laravel5.1 app. I use a couple views from the laravel app. How can I shorten the the following url
http://wordpressapp.com/laravel-app/public/item/view/18
I would like to remove /larave-app/public/ from the url so that when they click on the link the url shows as
http://wordpressapp.com/item/view/18
I am not sure if I need to update the .htaccess file in the laravel-app/public folder or the .htaccess file in wordpress or in both files. Thanks
I'm not an .htaccess expert but I know this trick has worked for me in the past:
RewriteRule ^laravel-app/public/(.*)$ /$1 [L,NC,R]
I imagine that the .htaccess file in the root of the site (WP) would need to be edited for this. I'm not sure what impact the "L" in the rule will have on the laravel app, perhaps it's worth giving it a try and testing?
This site: https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/ has some interesting explanations for you if you need more customisation.
I want to create http://localhost/Symfony/temp/.
In temp will be a basic index.html and some images. If I create the folder right now and put the index.html file in /temp/ I get a 404.
How do I get a normal response from http://localhost/Symfony/temp/index.html?
Requests going to temp/ are being caught by Symfony's default .htaccess. You'll have to add following:
# allow access to temp
RewriteRule ^temp.* - [QSA,L]
If you want it to work even with app_dev.php just change it to ^[app_dev.php/]*temp.*.
But I'm more interested why do you want to do that in root directory and not in static files directory (eg. web/static/temp). You wouldn't need to mess around with .htaccess and you'd be able to link to such images with asset(...).
Here's the solution I eventually came up with.
All I did was create a .htaccess file in /temp/ and inserted:
allow from all
Since I was getting a 404 error and all the other symfony folders had a .htaccess with
deny from all
I reversed engineered an answer.
Hope this helps someone else.
I'm completely new to Symfony 2 and i can't really understand the folder structure and organization of a project. I know what a bundle is, but what is unclear to me is:
what's the main directory (the directory to be copied on the web server for deployment)
where assets (css, javascript) should be placed
if (and how) environment should be changed when publishing my website
I've already read the book on Symfony website and i can't find those answers.
The web root of a Symfony2 app is the 'web' directory, but when you push to production the entire symfony2 project should be pushed not just the web root.
From the symfony2 book
app/: This directory contains the application configuration;
src/: All the project PHP code is stored under this directory;
vendor/: Any vendor libraries are placed here by convention;
web/: This is the web root directory and contains any publicly accessible files;
The assets should be kept in the bundles 'Resources/public/[css/js/images]' folders. From here you would have to copy or symlink those directories into the web root to make them accessible. Symfony2 comes with a command line utility located in the 'app' directory. app/console assets:install web --symlink command executed from the command line of your symfony2 project root will install all of the bundle's assets for you.
To change environments and you are using Apache you would use a .htaccess file and mod_rewrite to select which environment you would want to use
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
using /app.php puts me into production mode and using /app_dev.php would put me in development mode.
The main directory contains the app folder.
The assets should be
placed in the bundles folder they're related to. This folder is named
"public".
Read this. All you need to do is remove the app_dev.php file.
I have WAMP installed on my pc where I would like to run Drupal 6.
When I'm installing Drupal, I get the option to activate Clean URLs.
First I put my Drupal install in the www folder and I could choose to enable the clean URLs, but for backup reasons I moved it outside the www folder and created an alias the would point to the folder.
When I installed Drupal again, I couldn't choose to enable clean URLs anymore; the option was grayed out.
I would like to know why this happens; it seems some Apache module or PHP extension isn't available outside the www folder.
Just to be sure, I also tried an XAMPP install and created an alias with the some code lines as in the WAMP server but that worked, for some reason. The Apache version in WAMP isn't the same as the XAMPP install but I don't really think that is relevant.
I believe it's an config error in WAMP but I can't find out what.
Clean URLs doesn't work in the directory you copied Drupal because for that directory the directive AllowOverride is not set to All.
Drupal requires that every directives found in .htaccess files are enabled, in order to enable clean URLs; the directive AllowOverride, when set to All, allows to use all the directives that a .htaccess can contain.
The reason that in one case you can select the the option to enable the clean URLs, and in the other case is not selectable, is that Drupal, during its installation verifies the server is set to work with clean URLs, and change the form field to read-only if the server cannot support such feature.
To notice that the .htaccess file provided from Drupal can possibly need to be edited, in order to enable the clean URLs, as reported in the following comments, found inside the .htaccess file.
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /