wordpress multisite with sub-domain pretty permalinks - wordpress

i am trying to set up a wordpress (3.4.2) multisite. The current site already has the following apache rules applied, which i do not have the permissions to edit
<VirtualHost xx.xx.xx.xxx:80>
ServerName foo.example.nl
ServerAlias www.foo.example.nl
DocumentRoot /web/sites/example.nl/foo/www
RewriteEngine On
<Location />
Allow from all
</Location>
</VirtualHost>
this works fine however i found that trying to set up permalinks with 'Post name' options always gives me a 404 redirect.
http://foo.example.nl/post1 = 404 Not Found
at the moment i have un-installed multisite just to try and get the pretty urls working with the sub-domain but after trying lots of different variations of my .htaccess but nothing seems to be working. here is the current .htaccess wordpress generates:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Unfortunately you are probably limited from using .htaccess to configure the RewriteRules. If you referent to the Wordpress documentation on Using "Pretty" Permalinks you will see that you need to have Options FollowSymLinks enabled as well as AllowOverride Fileinfo or AllowOverride All to be able to use the pretty URL configuration in .htaccess. Since these don't seem to be set your <VirtualHost> it is likely your problem, since they are typically not set at a higher level in the Apache configuration.

Related

Wordpress Permalink Issue w/ Subdomains

My setup: I have domain.com pointing to Server 1 and have set up blog.domain.com to point to another wordpress Server 2 that hosts multiple wordpress sites. Server 2 has multiple wordpress sites in a single Ubuntu server as per these instructions. Because this manual is outdated, I also follow wordpress virtual host configuration based on Step 4 detailed in this post. Describing my setup up front because I'm not sure if my problem is because of this setup.
Question:
Based on this setup, Wordpress works fine with the default permalink option. Below are the details in my conf file
DocumentRoot /var/www/domain
ServerName blog.domain.com
ServerAlias blog.domain.com
<Directory "/var/www/domain">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
When plain permalinks are selected, my htaccess file in /var/www/domain is empty and everything works fine.However, when I change the permalink to Post name (blog.domain.com/sample-post/) the homepage (blog.domain.com) works fine but my individual post url (blog.domain.com/sample-post/) does not work. My htaccess file looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
WordPress Address (URL) = blog.domain.com
Site Address (URL) = blog.domain.com
Could you please help resolve this. I'd like permalinks to be enabled but have been stuck with this issue for several months. Really appreciate all your comments & feedback.
I was able to resolve this by following instructions by Robert in this thread - WordPress Multisite 404 error on posts and subsites

Wordpress permalinks fails with virtualhost

I have a wordpress blog in a local server: /var/www/html/blog
(In the root dir '/var/www/html' there are other pages i shouldn't move, so I cant't put the wordpress blog in the root)
I bought a domain name and I've assigned it to this blog with a virtualhost. Then I activated the permalinks in the wordpress blog.
The problem is that when I go to mydomain/index.php or mydomain/, it shows a "Apache 2 Test Page" and in the apache error log it writes this message:
Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /var/www/html/blog/
If I go to mydomain/wp-login.php, it's right. If I go to mydomain/section/blabla/, it's right. But the index page fails.
If I comment the .htaccess file I have put in the wordpress blog, the index page works, but pages like mydomain/section/blabla/ doesn't.
This is my virtualhost config code:
<VirtualHost *:80>
ServerAdmin ...Mymail...
DocumentRoot /var/www/html/blog
ServerName ...mydomain...
</Virtualhost>
And this is my .htaccess in the wordpress directory:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Solved.
Finally I moved the blog files to the root apache directory. Then I removed the virtualhost and I created a redirection rule: mydomain/ -> mydomain/index.php
And it works.
Try putting
Options +FollowSymLinks
at the top of your .htaccess file

HTTP 404 with Post name permalink

Okay so I've just create the first page on this site. It works when I use the default permalink settings.
If I change the permalink settings to use Post name, then I get an HTTP 404.
I'm not sure what's gone wrong or if I've broken anything. Can anyone help me fix?
The site is hosted on apache.
Are you using XAMPP or MAMP? There are a couple of common hiccups with those environments, taken from the WordPress Codex: Fixing Permalink Problems
Users of XAMPP (Windows): Some versions of XAMPP do not enable
mod_rewrite by default (though it is compiled in Apache). To enable it
— and thus enable WordPress to write the .htaccess file needed to
create pretty permalinks — you must open apache/conf/httpd.conf and
uncomment the line LoadModule rewrite_module modules/mod_rewrite.so
(i.e., delete the hash/pound sign at the front of the line).
Users of WAMP (Windows): Some versions of WAMP (all versions?) do not
enable mod_rewrite or permit following SymLinks by default. To enable
the required functionality navigate to the apache/conf/httpd.conf
file, open with a text editor and uncomment the line LoadModule
rewrite_module modules/mod_rewrite.so (i.e., delete the hash/pound
sign at the front of the line). Then further down in the same file
there is a section that starts with the line "Options FollowSymlinks".
Change the second line in that section from "AllowOverride none" to
AllowOverride all. Save edited httpd.conf and restart all WAMP
modules. Your permalinks should now work.
You might also see Permalinks without mod_rewrite if your sandbox doesn't have mod_rewrite available.
Apache
If you are using Apache there are usually two other culprits to broken permalinks: .htaccess isn't being generated (because of permissions settings) or Apache's AllowOverride directive isn't enabled.
First, if you SSH into your server, do you see a generated .htaccess file in the root? If not, WordPress might not have permissions to write that file. It's also possible the file does exist, but that WordPress cannot edit it. In either case, you can chmod that file (and create it if it doesn't exist) to 666.
Next, ensure your Apache config has the following settings:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
Finally, read through the Fixing Permalink Problems section of the WordPress Codex. There are several other tips and suggestions on why permalinks might not work.
In my case, firstly I had to update the .htaccess file inside my website root folder:
# 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
WordPress does this automatically if it has write permission. Otherwise it'll complain it can't write to it, and give the above code sample so you can manually update the .htaccess.
After that, I edited the apache2.conf file. In Linux, it resides in /etc/apache2/apache2.conf, there will be a section like this:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Change AllowOverride None to AllowOverride FileInfo.
Finally, execute the following commands:
sudo a2enmod rewrite
service apache2 restart
All these steps were necessary in order to work.
found this post on another site helped many people already
I finally managed to solve the problem! The solution: I was using a custom permalink structure http://kyl.fi/%category%/%postname%/. I removed the trailing slash (i.e. the last /) and voila. However, I'm quite sure I used a permalink structure with the trailing slash before without any problems, so I'm still confused and would be interested the hear more about this issue if somebody has an explanation.
All the standard permalinks have a trailing / in there.
in centos 8 and apache 2.4
look in /etc/httpd/conf.d
in your site .conf file add AllowOverride All, example like this
<Directory /path/to/site>
#add the following setting to allow .htaccess in your web dir to work
AllowOverride All
</Directory>
MY 80 LISTEN PORT
#Listen 80
<VirtualHost *:80>
DocumentRoot "/var/www/mysite.com"
ServerName www.mysite.com
# Other directives here
<Directory "/var/www/mysite.com">
Options FollowSymLinks
AllowOverride All
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mysite.com [OR]
RewriteCond %{SERVER_NAME} =mysite.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
MY SSL VIRTUAL HOST:
<IfModule mod_ssl.c>
<VirtualHost *:443>
DocumentRoot "/var/www/mysite.com"
ServerName www.mysite.com
# Other directives here
<Directory "/var/www/mysite.com">
Options FollowSymLinks
AllowOverride All
</Directory>
ServerAlias mysite.com
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/mysite.com/fullchain.pem
SSLCertificateKeyFile /live/mysite.com/privkey.pem
</VirtualHost>
</IfModule>
Restart apache service.
Check your .htaccess (in my site the .htaccess is located in /var/www/mysite.com
My .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^helloWorld/?$ /index.php [NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
look helloWorld rewrite rule.
If you invoke url www.mysite.com/helloWorld and the browser show your homepage, the configuration is working and the permalink path to site works.
In my case, I am using the NGINX web browser with my WordPress installation. The fix is to add the following code snippet to the NGINX Directives:
location / {
try_files $uri $uri/ /index.php?$args;
}
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ {
expires max;
log_not_found off;
}
If you are using the excellent (open source) ISPconfig.org CPanel substitute, then go to your Sites page, under the Options tab, enter the above code snippet for NGINX Directives. ISPconfig has a feature to add common code snippets for quick access under the Options tab.
After making the above fix, I was able to use any of WordPress' Permalinks options.
Tested Working Solution:
in your apache2 config file for example:
/etc/apache2/sites-enabled/000-default.conf or mysite.conf etc ..
Make sure you have set param and not empty: ServerName www.example.com or 123.212.333.111
Also make sure You have set directory rules as below (Your rewrite rules may not have taken effect in the .htaccess hence you put it here and try finding out Why .htaccess does not work .htaccess not working apache):
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</Directory>
Must be 2 point check:
1. Add code to .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
And Permission of .htaccess file, must be: 644
My solution was add this code in /etc/apache2/sites_available/000-default.conf
<Directory "/var/www/mysite.com">
Options FollowSymLinks
AllowOverride All
</Directory>
I'm on Apache 2.4.46 (Ubuntu)
Thank you

Wordpress subpages throwing 404 after restoring

I am a newbie to wordpress though I have programming background. Recently I moved a wordpress website from justhost shared server to a
linode vps server (Ubuntu OS). I did following steps to achieve it
Set up apache2 server on vps
Set up virtualhost on vps
Created a directory under /var/www/ftpadmin/www/
Note. ftpadmin was created to restrict ftp access to files under that folder. I could make work static html and php websites after doing so.
Took backup of database and wp-content folder from justhost server of respective wordpress website.
Now on vps, at specified location above, first I download latest version of wordpress and unzipped the files.
Created database of same name at mysql and then imported original to the same database.
replaced new wp-content folder with the one from original one.
I was following instructions on https://www.digitalocean.com/community/articles/how-to-set-up-multiple-wordpress-sites-on-a-single-ubuntu-vps.
restarted apache server. Now I could access the home page.
I corrected the database values for wordpress url and site address url to new one at older location and reloaded database which helped me access dashboard and login pages also.
I created a .htaccess file like mentioned in http://ahsan.vimmaniac.com/blog/enabling-wordpress-permalinks-on-ubuntu/.
I also changed "AllowOveride" under both section in /etc/apache2/sites-available/ as
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /var/www/ftpadmin/www/domainname>
RewriteEngine On
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>
restarted service apache once again.
One final point, I am using a custom template and so I have a header.php and header-sub.php file for homepage and navigation.
Now here is the problem. When I click on any submenu I get "Internal Server Error".
If I remove .htaccess and reload apache server. Now I get 404 error while clicking on and submenu.
Any help is highly appreciated? I looked at various sites to collate these many steps and execute. I have no Idea what I should do to correct this situation. But when I go dashboard -> All pages, I can find all pages existing there with contents.
Thanks in Advance
Fayaz
EDIT
Added .htaccess file from comment:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/ (wordpress replaced with my domainname, bottom also)
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
I got the above problem fixed by just replacing
RewriteBase /wordpress/ as "RewriteBase /"
and
RewriteRule ./wordpress/index.php [L} as "RewriteRule . /index.php [L]".
in .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Finally fixed this errow after browsing for a couple of hours and trying many options.
In this block in your Apache httpd.conf file, (located in my CentOS instance at $ sudo vi /etc/httpd/conf/httpd.conf)
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
change AllowOverride None to AllowOverride All.
Src: https://wordpress.org/support/topic/secondary-or-child-pages-returning-a-404-error-after-wp-34-update#post-3830892

WordPress index page is giving 404

My WordPress installation is in a different folder from my main site:
/var/www/html/wordpress <= WP installation
/var/www/html/main-site <= main site
I would like to have WP display when someone visits /blog from my main site:
http://www.main-site.com/blog (Note: main-site is used as a generic placeholder for the real site because it is not launched yet)
I have set up an alias in my httpd conf file:
Alias /blog /var/www/html/wordpress
<Directory /var/www/html/main-site>
DirectoryIndex index.php
Options -MultiViews
AllowOverride All
order allow,deny
allow from all
</Directory>
I have the following as my .htaccess file for WP:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
I get a 404 when I visit http://www.main-site.com/blog but when I visit http://www.main-site.com/wp-admin/index.php, it works (but I get a 404 if I visit /admin). Visiting the sample blog post and sample page also works for me.
http://www.main-site.com/blog/hello-world/
http://www.main-site.com/blog/sample-page/
It looks like rewrite is working but my /blog index page doesn't work.
Any suggestions would be greatly appreciated.
Thanks,
Allen
Finally figured this one out! It turns out that Passenger was enabled and I had to disable it.
Alias /blog /var/www/html/wordpress
<Directory /var/www/html/main-site>
PassengerEnabled off
DirectoryIndex index.php
Options -MultiViews
AllowOverride All
order allow,deny
allow from all
</Directory>

Resources