How to run a symfony project without having this folder structure - symfony

whenever i try to run my project i get the folder structure only.Why?
Index of /my_project
Parent Directory
README.md
bin/
composer.json
composer.lock
vendor/
web/
Apache/2.4.7 (Ubuntu) Server at localhost Port 80

You need to configure your .htaccess or httpd.conf to access the web folder
Solution #1:
Create a .htaccess file with the following file-contents in the DocumentRoot folder (basically the place where you see this folder structure)
Options +FollowSymLinks +ExecCGI
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
RewriteBase /web
# we skip all files with .something
RewriteCond %{REQUEST_URI} \..+$
RewriteCond %{REQUEST_URI} !\.html$
RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ app.php [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
Solution #2:
You can also adjust the httpd.conf depending on your web-hosting provider, if that's the case I would consult this page on symfony: http://symfony.com/doc/current/setup/web_server_configuration.html
Update:
Please mark this question as answered if it answered your question

Related

Using htaccess how to serve a subfolder as a WordPress page?

What I'm trying to do is server a subfolder: /subsites/brighton/ when the url domain.com/pop-up-in-brighton/availability is visited (that url is/can be a WP page. Doesn't matter to me). The site is build on wordpress so that domain is itself the result of an apache rewrite.
I've looked at RewriteRule examples and tried to adapt them but failed miserably. Can anyone help?
Whether it needs to be a rewriterule or maybe an alias? It's shared hosting so only really have access to the htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/pop-up-in-brighton/availability /subsites/brighton
RewriteRule . /index.php [L]
</IfModule>
Thanks!
i think what you need to check is the virtual server directive, you can create a new website with it's own folder and IP.
<VirtualHost 10.20.30.1:80>
ServerAdmin webmaster#host.example.com
DocumentRoot /www/docs/host.example.com
ServerName host.example.com
ErrorLog logs/host.example.com-error_log
TransferLog logs/host.example.com-access_log
</VirtualHost>
Virtual server directive
also check this article about virtual hosts and .htaccess
.htacess and VH
You need to install wordpress in your sub directory /subsites/brighton and you can follow these instructions for using a sub directory.
http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
Then you can point to that directory from /pop-up-in-brighton/availability using mod_rewrite in the .htaccess of you root directory.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com$
RewriteCond %{REQUEST_URI} ^/pop-up-in-brighton/availability [NC]
RewriteRule ^(.*)/?$ /subsites/brigton [L]
See how that works. Replace yourdomain with your real domain.

WordPress Permalinks Doesn't Work

I'm trying to create pretty permalinks through WordPress and I keep getting 404 errors. I've scoured the internet and I can't find any solution. I've never had an issue with this before so I'm totally stumped.
The hosting is under Network Solutions. I called them and they sent me this link: http://www.networksolutions.com/support/PHP-ini-for-UNIX-Shared-Hosting-FAQ
What I've tried:
1. Adding a php.ini file to my root.
2. Adding a php.ini file to the cgi-bin folder
3. Adding the rewrite commands to my .htaccess file (which is located in the root of my website).
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /stage/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /stage/index.php [L]
</IfModule>
# END WordPress
After each of these, I've resaved the permalink settings to flush the changes.
I still keep getting a 404 error.
I had the same problem on an Ubuntu 14.04 server which is running as a staging server.
In this case the rewrite module was not enabled by default; so Pagination and "non-ugly" Permalinks were not working (as they rely on .htaccess rewrite rules to work).
You have to edit the Apache conf file (in Ubuntu 14.04: /etc/apache2/apache2.conf) and change the AllowOverride setting from None to FileInfo
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride FileInfo
Require all granted
</Directory>
You may need to enable the Rewrite module:
sudo a2enmod rewrite
and to complete you will need to restart
sudo service apache2 restart
That's been bugging me for a month or so, now, so kudos to the solution found:
https://askubuntu.com/questions/48362/how-to-enable-mod-rewrite-in-apache
Login to your server using FTP, and modify the .htaccess file which is located in the same location where folders like /wp-content/ and /wp-includes/ are located. The easiest thing you can do is to temporarily make the file writeable by changing the permissions to 666. Then repeat the original solution. Don’t forget to change the permissions back to 660. You can also manually add this code in your .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Another solution: Put index.php at the start of your custom permalink structure, for example:
/index.php/%year%/%monthnum%/%day%/%postname%/

deny file request and redirect to .php page using .htaccess

I'm working with wordpress and I am using .htaccess, but I don't really understand its functionality.
The scenario is the following:
When user tries to reach a file from upload directory (example: http://[localhost]/wordpress/uploads/video.mp4) he is redirected to a php page which decides if the user has a permission to download/view the file or not (for example, redirecting to the following: http://[localhost]/wordpress/serve.php?filename=video.mp4).
Does anyone knows what should I do with the .htaccess?
In which directory should the .htaccess file be placed?
You can use your WordPress root .htaccess file for this, or you can create one in the uploads directory. I'd recommend sticking to the file you're already using for WordPress.
/wordpress/.htaccess amended content
RewriteBase /wordpress/
# ^ your base should already be set - if it hasn't, put this just under RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^uploads\/(.*) serve.php?filename=$1 [R,L]
Note: If you do not want to redirect, you can still disguise it under the actual file name, and it will still return the PHP response. You can do this by removing the R flag. (This will keep the originally-requested URL in the address bar.)
EDIT: based on your comment, and revealing where your .htaccess file resides, try the following:
RewriteBase /wordpress/wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*) /wp-content/themes/fun&share/serve.php?filename=$1 [R,L]
EDIT 2: My apologies, I did not account for the RewriteBase. Please see the code below:
RewriteEngine On
RewriteBase /wordpress/wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*) ../themes/fun&share/serve.php?filename=$1 [R,L]
This .htaccess file must be placed in your uploads folder.
Try adding these rules to an htaccess file in your /wordpress/uploads directory:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ /wordpress/serve.php?filename=$1 [L]

Remove /drupal from url path

I'm working on a Drupal website, in which I want to display my website as www.ex.com instead ex.com/drupal
I have tried using this code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^202.158.43.33$ [NC]
RewriteRule .* 202.158.43.33 [L,R=301]
RewriteRule ^$ drupal/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/drupal%{REQUEST_URI} -f
RewriteRule .* drupal/$0 [L]
RewriteCond %{REQUEST_FILENAME} ! -f
RewriteCond %{REQUEST_FILENAME} ! -d
RewriteRule .* drupal/index.php?q=$0 [QSA]
</IfModule>
which is saved in root folder and I have changed the $base_url = 'http://www.ex.com'; in drupal/sites/default/settings.php
When I run my website, I see the url as: 202.158.43.33/202.158.43.33/202.158.43.33/202.158.43.33.........
Could someone tell me how to fix this problem.
Instead of writing your own code, use Drupal's default .htaccess file. Then uncomment the last two lines of this snippet of code.
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Virtual host file Configuration:
<VirtualHost *:80>
ServerAdmin me#mysite.com
DocumentRoot "/var/www/http/mysite.com"
ServerName mysite.com
ServerAlias www.mysite.com
</VirtualHost>
The document root should point to the Drupal you're navigating to under your current site, the "/drupal" subdirectory.
Do you NEED drupal files to be on separate folder in this domain? I'm just asking because there is the obvious answer to make one's drupal site run in root directory: Just move all files from drupal folder (all the files that are located into "drupal" folder) to the parent (root) directory and your site will display on www.yourdomain.com, rather than on www.yourdomain.com/drupal

.htaccess file: redirect files inside of folder

I am trying to make my server look neat locally (I swear I am OCD) and what I am doing is combining a wordpress blog with all of my subdomains.
My wordpress blog is my main website, example.com. Whereas my subdomains are at sub.example.com.
Right now, I have this setup:
public_html
( wordpress files here )
subdomains
sub1 - (sub1.example.com)
sub2 - (sub2.example.com)
sub3 - (sub3.example.com)
blog - (empty)
The blog folder is empty. However, I want to move all the wordpress files to blog/ but keep the blog's URL at http://www.example.com/. Thus, http://www.example.com/index.php will go to http://www.example.com/blog/index.php, as well as all directories in blog/.
This code did not work:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ blog/$1.php [L]
It instead gave me Index of /. Is there any possible way to do this?
The best way to do this would be to just move all the files to /blog and then redefine your Apache siteroot for the www. domain to include the blog folder like
DocumentRoot /(path)/public_html -> DocumentRoot /(path)/public_html/blog
That way you won't even have to use .htaccess rewrites to correctly map your blog folder to the root of the www domain.
If for some reason you can't do that, lets take a look at your htaccess rules:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
These 2 conflict. Without an [OR] at the end of your RewriteCond, the rules act as AND operator meaning each condition must be true. So you will never had a match that is both NOT a file (!-f) and IS a .php file (.php -f).
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ blog/$1.php [L]
Here you are appending .php to a match that already contains .php per the RewriteCond.
I would try the following:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule ^(.*)$ /blog/$1 [NC,L]
If you move all files into /public_html/blog and there will be nothing in /public_html except your /blog and /subdomain folders, you really don't even need !-d & !-f since there would be no files or folders to match (except your subdomain folders but I'm not sure you want those being served up under www domain anyways). Seeing as how your wordpress css,js and images are now also going to be in /blog you would want their urls to be forwarded on too. Also you don't really need RewriteBase / when working in the root folder. Just start your target urls with a slash like /blog/$1. Finally I added in a condition to check that the target request doesn't already contain the /blog in order to prevent infinite redirects...
Don't forget that even with the redirect in there, you will still need to have your site address configured with /blog -
http://www.example.com/blog/
in the Wordpress settings.
Here is another working example:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC]
RewriteRule ^$ /blog/$1 [R=303,L]

Resources