Since I've setup a wildcard VirtualHost my htaccess files does not work anymore
The http-vhosts.conf
NameVirtualHost *
<VirtualHost *:80>
ServerName default.dev
VirtualDocumentRoot /Users/[UserName]/Sites/%-2
<Directory /Users/[UserName]/Sites/%-2>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
the .htaccess (WordPress default)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I can access http://wordpress.dev and also the backend but not a page like http://wordpress.dev/page (causes a 404 error).
I can set the permalink structure to default but I would like to have "nice URLs"
I'm on a local development environment on Mac OS X 10.10 with Apache 2.4
Change your VirtualHost definition to:
<VirtualHost *:80>
ServerName default.dev
VirtualDocumentRoot /Users/[UserName]/Sites/%-2
<Directory /Users/[UserName]/Sites>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
i.e, root the directory definition to Sites, not to the virtual directory.
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>
Normal VHOST:
<VirtualHost *:80>
DocumentRoot /var/www/html/app/current/web
ServerAdmin me#app.foobar
ServerName app.foobar
ServerAlias www.app.foobar
<Directory /var/www/html/app/current/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options Indexes FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !HTTP/1.1$
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
</IfModule>
</VirtualHost>
HTTPS VHOST:
<VirtualHost *:443>
DocumentRoot /var/www/html/app/current/web
ServerName app.foobar
ServerAdmin me#app.foobar
<Directory /var/www/html/app/current/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite>
Options Indexes FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !HTTP/1.1$
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
SSLEngine on
SSLProtocol +TLSv1 +TLSv1.1 +TLSv1.2
SSLCertificateFile /ssl/app.foobar/app.foobar.crt
SSLCertificateKeyFile /ssl/app.foobar/app.foobar.key
SSLCACertificateFile /ssl/app.foobar/app.foobar.ca-bundle
</VirtualHost>
As the title says when I use regular port 80 the urls are rewritten to use app.php but when I try to use https port 443 I get a directory listing instead. How do I get the url rewritten with https like it does with http?
I solved this by using the FallbackResource directive available in Apache 2.2.16+.
In the official Symfony docs this directive is not used to remain backwards compatible with older version of Apache. Discussion is here.
Code example:
<Directory /var/www/html/app/current/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
FallbackResource /app.php
</IfModule>
</Directory>
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.
I'm been trying to figure this one out for ages but I can't seem to do it. I have an ubuntu 10.04 server with wordpress installed on it. I am trying to make my wordpress use "Pretty" permalinks however every time I try it doesn't seem to work.
This is my apache config:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/wordpress
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/wordpress>
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 /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.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>
The .htaccess file is owned by root and it is chmod to 644 (security reasons) and it looks like this:
# 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
Suggestions and a solution would be most welcomed