Here's an example of a page that works perfectly fine on the dev env and returns a 404 error on the prod env
Not Found
The requested URL /app/reporter/ was not found on this server.
Apache/2.4.7 (Ubuntu) Server at symfony.dev Port 80
don't let yourself confuse by the /app/ route, this in a real route and has nothing to do with app.php
running php app/console router:debug --env=prod does confirm there's no problem with router :
[router] Current routes
Name Method Scheme Host Path
reporter ANY ANY ANY /app/reporter/
Of course, before posting this message, I :
cleared the cache, with console cache:clear --env=prod, as well as directly deleting cache files but this didnt change anything.
double-checked mod_rewrite was on in phpinfo
Anyway, my guess is the error comes more from Apache so here's my conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName symfony.dev
SetEnv SYMFONY__TENANT__ID "123"
DocumentRoot /var/www/html/Symfony/web
# <Directory />
# Options FollowSymLinks
# AllowOverride None
# </Directory>
<Directory /var/www/html/Symfony/web >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error-symfony.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access-symfony.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
in /var/www/html/, there's only a symlink:
lrwxrwxrwx 1 root root 29 mai 13 2014 Symfony -> /home/me/path/to/symfony
and i didnt change anything in the default symfony /web/.htaccess :
without comments for readability's sake
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
Apache error log confirmed the error came from there :
[negotiation:error] [pid 1583] [client 127.0.0.1:44590] AH00687: Negotiation: discovered file(s) matching request: /var/www/html/Symfony/web/app (None could be negotiated).
As my understanding of Apache is seriously limited, i google the error and found this topic :
http://www.bennadel.com/blog/2218-negotiation-discovered-file-s-matching-request-none-could-be-negotiated.htm
So i ended up simply removing the MultiViews option of my vhost conf and it solved it.
As the above give link is mentionning,
This goes to show you how bad it is to simply enable settings when you are not sure what they do.
Related
On my Apache server I have a WordPress installation working on www.domain.com and I want to add a Symfony4 installation on www.domain.com/symfony. Symfony routes are taken to the WordPress 404 page (but still are the correct URL i.e. www.domain.com/symfony/about). However, if there are NO routes defined in my Symfony app, then the base www.domain.com/symfony/ URL will correctly display the Symfony4 getting started page. What is wrong in my Apache conf files?
Web server is Apache 2.4, I have tried using Alias and AliasMatch directives in the /etc/apache2 conf files. Alias displays WordPress 404 for all Symfony routes and AliasMatch appends many /index.php's onto the URL and displays the same 404. I tried to copy what phpmyadmin does with its Alias /phpmyadmin /usr/share/phpmyadmin
# /etc/apache2/sites-available/wordpress.conf
<Directory /var/www/wordpress>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
ServerAdmin me#myemail.com
DocumentRoot /var/www/wordpress
</VirtualHost>
# /var/www/wordpress/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# /etc/apache2/sites-available/symfony.conf
Alias /symfony /var/www/symfony/app/public
<Directory /var/www/symfony/app/public>
Options FollowSymLinks
AllowOverride All
Require all granted
Allow from All
FallbackResource /index.php
</Directory>
# /var/www/symfony/app/config/routes.yaml
about_index:
path: /about
controller: App\Controller\AboutController::index
I expected www.domain.com/symfony/about to go to /var/www/symfony/app/public/index.php and route to App\Controller\AboutController::index, but it looks like WordPress is trying to find the page /symfony/about and 404's.
When I change my Alias /symfony /var/www/symfony/app/public to AliasMatch ^/symfony.* /var/www/symfony/app/public it changes the Symfony URL to www.domain.com/symfony/index.php/index.php/index.php/index.php/index.php/index.php but has the same result (WordPress 404 page). None of my changes have impacted the WordPress part at all - it still functions perfectly.
EDIT 1
Tried a new conf to test if it's my symfony config - it works as expected so I just think it must be something in my Apache confs. This config treats the symfony app as the main site and wordpress is totally disabled:
# /etc/apache2/sites-available/symfony_only.conf
<Directory /var/www/symfony/app/public>
Options FollowSymLinks
AllowOverride All
Require all granted
Allow from All
FallbackResource /index.php
</Directory>
<Directory /var/www/symfony/app/public/bundles>
FallbackResource disabled
</Directory>
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
ServerAdmin me#myemail.com
DocumentRoot /var/www/symfony/app/public
</VirtualHost>
Looks like I got a working conf now. Not sure if it's even resulting in any different configuration than the one I had. I also did a lot of php bin/console cache:clear as I was even getting 404 and 500 errors on the little debug bar at the bottom of the symfony welcome page (not displayed on the bar, but the bar actually wouldn't properly load). The below file is my entire conf which I combined into one file. It serves from my Symfony4 app if the url path begins with /symfony, and the routes all work.
# /etc/apache2/sites-available/wordpress_symfony.conf
Alias /symfony /var/www/symfony/app/public
<Directory /var/www/symfony/app/public>
AllowOverride All
Require all granted
Allow from All
FallbackResource /index.php
</Directory>
<Directory /var/www/symfony/app/public/bundles>
FallbackResource disabled
</Directory>
<Directory /var/www/wordpress>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
ServerAdmin me#myemail.com
DocumentRoot /var/www/wordpress
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Also I added the symfony/apache-pack with composer which added this .htaccess in the symfony public directory. The docs said I can get improved performance by moving all these rules into my .conf file and disabling overrides:
# /var/www/symfony/app/public/.htaccess
DirectoryIndex index.php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 307 ^/$ /index.php/
</IfModule>
</IfModule>
i started new project on symfony 2.8.2.
I added on my apache2 sites/enabled this vhost file, copied from symfony cookbook:
<VirtualHost *:80>
ServerName local.n-difference.fr
ServerAlias local.n-difference.fr
DocumentRoot /var/www/n-difference/web
<Directory /var/www/n-difference/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/project>
# Options FollowSymlinks
# </Directory>
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/project/web/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
ErrorLog /var/log/apache2/errors.log
</VirtualHost>
I did sudo service apache2 restart to refresh the server.
I access the project from another Dev PC with ssh, and of course, i added on this etc/hosts file:
192.168.1.20 local.n-difference.fr
The problem is when i try to access the url local.n-difference.fr, i have this www/ index page
Did i forget something ?
Thank's a lot for your help :)
(and sorry for my bad english)
I can't for the life of me figure out getting Wordpress to work with pretty permalinks on my Apache server. I've searched online and tried a myriad of combinations of things. The URL in question is www.trixiebangbang.com. I have a traditional LAMP stack running on Ubuntu all hosted with AWS.
I want the Wordpress "Day and Name" permalinks working. I have already selected that in Wordpress and updated my .htaccess file and given it 755 permissions:
# .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
That still results in a 404 error when I view my blog posts. For example if I go to this example blog post it doesn't work. I then updated my /etc/apache2/sites-enabled/000-default.conf configuration file to be the following:
# 000-default.conf file
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
I am very careful and sure to execute "sudo service apache2 restart" after every change I make before testing. Can someone please tell me what's wrong here? Thanks in advance.
After more searching I was able to piece together a solution that worked for me. I updated the 000-default.conf file to the following and restarted the server. I hope this helps someone else.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName trixiebangbang.com
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
I can't seem to figure this out. I'm using Apache 2.4.7 on Ubuntu 14.04 and I have mod_headers enabled. In my /etc/apache2/apache2.conf file, I have the following default Directory statements:
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
I'm trying to override the default apache2.conf config by using VirtualHosts for my actual website directory in /etc/apache2/sites-available/000-default.conf:
<VirtualHost *:80>
ServerAdmin blahblah#123456.so
ServerName 999.999.999.999
DocumentRoot /var/www/html/domains/website1
<Directory /var/www/html/domains/website1>
Options -Indexes +FollowSymLinks
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
The website works just fine but whenever I try to enable SEO friendly URLs, I get a 404 error stating the page does not exist. Here's the .htaccess file located in /var/www/html/domains/website1/ (It's a standard Wordpress .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
Any ideas would be greatly appreciated. Thanks!
Silly me. I figured it out as I was filling out the Tags section of the form and the tag mod-rewrite popped up as one of the suggestions. I needed mod_rewrite enabled! Durp. Well, thanks to the stackoverflow web developers for building that feature into the site :)
Domain is www.sandersonathletics.org
Wordpress 3.8.1, Multisite with Subdirectory.
The error thats cropping up is identified on the new subdirectory site;
www.sandersonathletics.org/football - Unformatted AND
www.sandersonathletics.org/football/wp-admin 404 Error
I've verified the .htaccess file matches what's in Wordpress.
I've verified the appropriate location of .htaccess (public_html root)
I've verified the wp-config file and that the location of the multisite data is in the right place and I've checked what's there.
I've reviewed entries in the mysql database and that the www. matches in wp-config, the database, etc. (The host suggested this)
I've renamed the plug-in directory to plugin-bak to debug a plugin issue. That had no effect.
I'm currently hosted with Dreamhost Shared servers.
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
Working solution Tested on Ubuntu 16.04 WP 4.9.7 and PHP7:
Source:
https://wordpress.stackexchange.com/questions/167294/multisite-404-error-for-subdirectory
Edit this file /etc/apache2/sites-enabled/.conf
to make it looks like this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /var/www/>
Options FollowSymLinks
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The part that makes it works is:
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /var/www/>
Options FollowSymLinks
AllowOverride all
Order allow,deny
allow from all
</Directory>
Restart apache:
sudo service apache2 restart
There you have it! test your sites.