Wordpress subpages throwing 404 after restoring - wordpress

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

Related

Wordpress page not found on AWS

I have transferred a wordpress website on AWS (EC2 and RDS-Mysql servers). The DNS has been setup in Route53.
The wordpress files has been located under directory:
/var/www/html
And the mysql database is imported on RDS. The home page looks fine but when I click on the other pages, it gives "404 not found" error. I have modified /etc/httpd/conf/httpd.conf file to allow WordPress to use permalinks:
<Directory "/var/www/html">
AllowOverride All
I have also checked the size of transferred files and they look as same as the main files.
Any help would be appreciated.
I could solve my problem by adding .htaccess file in the directory of my wordpress files.
# 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
http://guiem.info/permalinks-on-wordpress-amazon-ec2/
Try to follow these steps:
In the WordPress dashboard go to Settings > Permalinks
Without changing anything click on the Save button
And then try to click on the inner pages, it should load fine.
Why does this happen? When you change server, the paths and urls are changed. When you save permalink settings then WordPress will update its rewrite rules and so it will work fine.

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%/

wordpress multisite with sub-domain pretty permalinks

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.

Why do none of the pages in my Wordpress site work?

I am trying to move a Wordpress site to a new server. The domain name is also changing from "olddomain.com" to "newdomain.com."
To this end, I moved all the files over to the new server and set up a virtual host in Apache. I then used a script (http://interconnectit.com/124/search-and-replace-for-wordpress-databases/) to replace instances of "olddomain.com" with "newdomain.com."
The home page of my site is working when I visit it in a browser. However, none of my other pages such as "newdomain.com/about/" are working - they return 404s.
I checked my Apache error log and got the following log.
[client 69.184.72.91] File does not exist: /home/david/wordpressSiteFiles/about, referer: http://newdomain.com/
Why is Apache looking for a file called "about" on my server? Here is the .htaccess file I have now.
# 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>
Do you have allowoverride set on the server?
http://codex.wordpress.org/Using_Permalinks
allowoverride must be set in your httpd.config or your .htaccess will
be completely ignored.
Your server may not have the AllowOverride directive enabled. If the
AllowOverride directive is set to None in your Apache httpd.config
file, then .htaccess files are completely ignored. In this case, the
server will not even attempt to read .htaccess files in the
filesystem.
Source
http://wordpress.org/support/topic/wordpress-cant-find-my-new-pages
I had this same problem a few days ago and this fixed it!
Sounds like you have rewrite rules that need to be updated. Look for a .htaccess file.

Wordpress Permalinks not working

I moved my site from slichost to Amazon ec2. After moving i made necessary settings for wordpress. My first page for wordpress works fine, but the permalinks are not working.
Can anyone please let me know what changes are necessary to make the permalinks working.
Thanks
Check your apache configuration and verify that for the directory in which you store your Wordpress installation you have following settings enabled (probably you will have more configuration options for the specific directory, but these are the minimum required for Wordpress fancy permalinks):
<Directory var/www/>
Options FollowSymLinks
AllowOverride All
</Directory>
After moving to a new linux host and installing a fresh wordpress, we had to make ALL of the following changes in order to enable pretty permalinks.
Create .htaccess in the correct folder, containing the code as suggested by Krige.
Enable mod_rewrite on apache, then restart the server, as suggested by Mike Lynn.
Change the apache configuration to FollowSymLinks and AllowOverride All for /var/www/, as suggested by Cninroh. For us /etc/apache2/sites-enabled/000-default was the file we had to edit.
I was having issues getting Permalinks (other than default) to work on Mac OSX and the following was very much useful. It seems that by default Mac's are not .htaccess ready by default and Apache will ignore the file until certain files (specified on the links below) are modified:
http://wordpress.org/support/topic/getting-pretty-permalinks-working-on-a-mac-105-server
http://clagnut.com/blog/350/
Hope that helps!
Create a .htaccess file in your wordpress directory and put into it the following code:
# 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
Source
I was able to fix this by:
logging into wp-admin for my site
changing the Settings | Permalinks option to something different
save changes
changing the Settings | Permalinks option back to its original value
save changes
This seemed to re-enable permalinks, which did not originally work.
Try adding index.php/ before the permalink path.
While checking the apache configuration is essential and probably the first step, you also need to ensure that apache has the mod_rewrite module enabled... Depending upon the AMI from Amazon that you used, you will need to :
Install apache and conditionally enable mod_rewrite.
a2enmod rewrite
Restart the server
Aa
When you set permalinks option other than default, the following code is already posted in .htaccess file.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /callerdb/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /callerdb/index.php [L]
</IfModule>
# END WordPress
But that doesn't help as you already know.
So, this will work when you set rewrite_module, this can be done by going to "fix permissions" if available in your cpanel or you may contact your host.

Resources