Wordpress Error 404 after changing permalink on some pages - wordpress

I’m having a problem since changing my permalinks from default to postname on a wordpress site. I’m getting 404 errors on pages but only the ones that are within the submenu called menus, all the other pages are working fine.
I have been searching on and off for an answer to this for a couple of days now with no success. Someone suggested that it might be an error in the HTaccess file but I don't really know what I'm looking at. I tried generating a new one from Wordpress.org code I found but that just killed the site altogether so I changed it back to the old one. I can see the .htaccess inside the folder public_html there are some others in there with .bak which I assume are from backups I've made of the site. Here is a link to what I'm getting http://www.5thview.com/menus/nibbles/
Not sure why it’s just those pages that are affected other than they are in a submenu. I’ve no idea how to fix this.
I should add that if I switch back to default permalinks it works fine again…
I would need specific instructions if poss as I'm a bit of a newb to the coding side etc although I can find my way around if directed...
Any help would be greatly appreciated. Thanks...

The reason links are broken is that your host doesn't have root directive correctly set.
If you are using Nginx, change the virtual host conf file as below:
server{
location / {
try_files $uri $uri/ /index.php?q=$uri$args;
}
}
If your root wordpress is not the webroot but http://[domain.com]/wordpress/:
server{
location /wordpress/ {
    try_files $uri $uri/ /wordpress/index.php?q=$uri$args;
}
}
Don't forget to restart nginx service.
If you are using Apache, put .htaccess file under your root path, an add below lines
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Don't forget to restart apache service.

Related

Fishpig Wordpress Magento - http://example.com/blog resolves to www.example.com rather than www.example.com/blog

I have a working Fishpig Wordpress Magento instance on a production server.
All the green ticks show it has succesfully configured and when visiting
http://www.example.com/blog
it works. However when I try and and visit
http://example.com/blog
it sends me back to the magento home page at www.example.com .
I have tried setting the url in wordpress to both http://example.com/blog and http://www.example.com/blog but in both situations it always sends me to the home page at site.com.
This is a concern because most experienced web users will not type www when trying to access a location.
My htaccess is as generated by Wordpress and looks like
DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
#wp generated
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Please not the wordpress site files are located at site.com/wp and it is the fishpig extension which arranges the direct from the non existent /blog path.
First of all, to start of, one way to resolve the issue is to simply make your Magento website DEFAULT to not have the www. in the url.
In Magento, go to System > Configuration > Web.
In the "Secure" and "Unsecure" tabs, find "Base URL."
The value should look something like this:
http://www.site.com/
Replace ALL references to the domain so it shows:
http://site.com/
Unfortunately, there may be a lot of appearances of it throughout the site. You'll need to do the same thing elsewhere on the server.
If you really want your site/blog to say www., though, you'll have to properly forward the .htaccess file in Magento. I'm not too keen on how Magento's .htaccess file works, but I do know how to forward a url and keep all of its additional pages as well (however, Magento's setup may interfere).
The code should look something like this:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^site.com$ [NC,OR]
RewriteRule ^(.*)$ http://www.site.com$1 [R=301,L]
Again, I don't know how well this will work with Magento's set up, but I've successfully used the above code to redirect url's to the correct url I want. That code above was actually used on a wordpress site, though.
Check for Rewrite rules in Magento's .htaccess file and try putting this above it. Be careful, though; it is VERY easy to cause 500 internal server errors if you mess up the .htaccess file, so always keep a backup.
Try this out and I hope it helps.

Wordpress permalink structure change issue

I have seen some other posts on SO about this issue, however none of the suggested solutions did work for me, so I repost.
After changing my permalink structure to /%postname%/, none of the links is working. I get the following 404:
Not Found
The requested URL /my-post-name/ was not found on this server.
Apache/2.2.20 (Ubuntu) Server at mysite.com Port 80
When I get back to the default permalink structure it starts to work again, but I want to have /%postname%/ structure anyways.
My .htaccess file's chmod is 777.
After updating my permalink structure to /%postname%/, the .htaccess file generated by Wordpress is the following:
# 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 thoughts?
Edit:
I tried to change permalink structure to the following:
/index.php/%postname%/
and it happily worked. However, the problem is now, not surprisingly, the links are in the following form:
www.mysite.com/index.php/my-page.com
My question is how can I remove index.php from my links. When I remove it from the permalink structure (i.e., /%postname%/), my links no longer work.
PS: Instead of using blog entries I use only pages in my site. If it is necessary my site is: mll.sehir.edu.tr.
There are many ways how you can fix this issue, if you know the root of the issue.
Problem 1
Firstly, it may be a problem with your apache not having the mod_rewrite.c module installed or enabled.
For this reason, you would have to enable it as follows
Open up your console and type into it, this:
sudo a2enmod rewrite
Restart your apache server.
service apache2 restart
Problem 2
You may also, in addition to the above, if it does not work, have to change the override rule from the apache conf file (either apache2.conf, http.conf , or 000-default file).
Locate Directory /var/www/
Change the Override None to Override All
Problem 3
If you get an error stating rewrite module is not found, then probably your userdir module is not enabled. For this reason you need to enable it.
Type this into the console:
sudo a2enmod userdir
Then try enabling the rewrite module if still not enabled (as mentioned above).
To read further on this, you can visit this site: http://seventhsoulmountain.blogspot.com/2014/02/wordpress-permalink-ubuntu-problem-solutions.html
Sounds like a problem with symlinks on your server. Try this in your .htaccess and also please change it to 644 after making the change:
Options +FollowSymlinks
RewriteEngine on
# 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
I had the same problem but i am using other url structure /%category%/%postname%/
The problems with de 404 error is because even if you set a certain structure, wordpress is always trying to create the urls with the word "category" on the url.
Try to type your urls like this: yoursite.com/category/postname, if you are not getting any error now is because we are close to resolving the error. Now try to install this wordpress plugin http://wordpress.org/extend/plugins/no-category-base-wpml/ to remove the "category" base from urls
Let me know about your progress
Replace and try your .htaccess with this:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^hostname.com$
RewriteRule ^(.*)$ http://www.hostname.com/$1 [R=permanent,L]
I got this issue whenever i try to enable my site's permalink to mod_rewrite: "Pretty Permalinks". My site is one instance on AWS EC2.
404 Errors
Page Not Found
The requested URL .... was not found on this server.
Apache/2.4.7 (Ubuntu) Server at mydomain.com Port 80
I tried all above methods, but not being fixed.
At last, I checked the /etc/apache2/sites-available/wordpress.conf, I found I used public IP address assigned to each instance by AWS. Once I change it to the current mydomain.com, it's working.
Sometimes, wordpress.conf would be locked by httpd (web serser), we need to stop and start it after edit. We also need to use: sudo service apache2 stop/start so as wordpress.conf could be reload again.
Hope my experience could help others.

Wordpress is cut off when linking to pages using /index.php/page-name

I have posted this question on bitnami answers as well but I am refining it here. The relevant link is:
I am running the bitnami wordpress stack on my Kubuntu Linux machine. I am linking to pages internal to my site in my content with absolute links like this /index.php/page-name and my server is running at http://127.0.1.1/wordpress/. The appropriate relative links work correctly but the absolute links do not.
The behaviour I am getting with the absolute links is that the /wordpress/ path component is truncated when using /index.php/page-name and points to http://127.0.1.1/index.php/page-name instead of http://127.0.1.1/wordpress/index.php/page-name.
I am using the Post name permalink structure and my .htaccess file also has the following rewrite rules:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
Every time I click the link I get a 404 error with this message in the apache error log:
script '/home/nandu/wordpress-3.3.1-1/apache2/htdocs/index.php' not found or unable to stat
I am not sure why the wordpress part of the URL is getting cut off when my settings in the admin area show both the site url and address url pointing to http://127.0.1.1/wordpress.
Furthermore according to the wordpress codex /index.php/ should point to the site root.
I am at my wits end as far as this problem is concerned. Kindly do let me know if you require any more information.
Thanks in advance.
nav
I'm not sure why you're trying to write your links via index.php. You should create links that match the permalinks that WordPress itself would produce. So, instead of /index.php/page-name, you would put /wordpress/page-name.
I have succeeded in getting my bitnami wordpress stack to run wordpress on the root url http://127.0.1.1/ so that the links in my content will work identically to my production system.
Here are the steps I followed modify to suit your needs:
Edit the following lines in /<INSTALL_DIR>/apache2/conf/httpd.conf
from:
DocumentRoot "/<INSTALL_DIR>/apache2/htdocs"
to
DocumentRoot "/<INSTALL_DIR>/apps/wordpress/htdocs"
In the same file, also change the following directive
from
<Directory "/<INSTALL_DIR>/apache2/htdocs">
to
<Directory "/<INSTALL_DIR>/apps/wordpress/htdocs">
Go to /<INSTALL_DIR>/apps/wordpress/conf/wordpress.conf and comment out the following lines by prepending a #:
Alias /wordpress/ "/<INSTALL_DIR>/apps/wordpress/htdocs/"
Alias /wordpress "/<INSTALL_DIR>/apps/wordpress/htdocs"
In the same file change
from:
RewriteBase /wordpress/
to
RewriteBase /
In the same file, uncomment the following lines by removing the #:
#RewriteEngine On
#RewriteRule ^/$ /wordpress/ [PT]
Restart the bitnami apache server:
/<INSTALL_DIR>/ctlscript restart
Edit the following lines in /<INSTALL_DIR>/apps/wordpress/htdocs/.htaccess
from:
RewriteBase /wordpress/
to
RewriteBase /
and
RewriteRule . /wordpress/index.php [L]
to
RewriteRule . /index.php [L]
Login to PHPMyAdmin at http://127.0.1.1/phpmyadmin and go to the wp_options table change siteurl value
from:
http://127.0.1.1/wordpress
to
http://127.0.1.1
After this rename the index.html file in the /<INSTALL_DIR>/apache2/htdocs/ directory to old-index.html
Restart the bitnami apache server:
/<INSTALL_DIR>/ctlscript restart
Navigating to http://127.0.1.1/ should show the homepage of the site. There is some documentation on the bitnami wordpress docs about what needs to be done to change the root url but they seemed incomplete in terms of what I had to do to accomplish this.
Hope that helps someone. :-)
nav

Wordpress installed in root folder, subdomain now not working, GoDaddy host

please forgive me for being a complete beginner at this, I'd rather not have to try to deal with this myself but as GoDaddy support have not replied after 2 days I'm going to have to. I think my problem is the same as the one above, but I'm not 100% sure, so I'm reposting it, I'm not really confident enough to attempt to try the fixes I've seen here so I need someone to give me baby instructions?
Our original website (www.mwpics.com.au) was built in Dreamweaver etc, recently we created a new website in Wordpress, in a subdomain, then migrated it over to the root folder where it is now operating fine. I also moved the files for the old website into another directory which I called 'old', so they're all still there.
The problem is that I have a subdomain set up - which is still showing as set up in the control panel on godaddy the url is www.mwpics.com.au/clients and it is at www.clients.mwpics.com.au. This directory contains loads of other directories, each of which is password protected by .htaccess files and which our clients access directly (not through the site) to download their finished work. The test one and the one for random clients is www.mwpics.com.au/clients/temp - username and password both temp (the usernames are all the same as the directory names).
Since the WP install to the root directory the /clients extension no longer works (it should bring up an information page which is an .html index page in the directory) and the /clients/name extensions no longer works - it goes back to the wp site with a 'not found' error message. Strangely it does bring up the box for the username and password, but when you enter it it just goes back to the 'not found' message.
Someone told me it was the .htaccess file - so as an experiment, I renamed the .htaccess file in the root directory and then copied the .htaccess file from the old root files into the root directory, eureka! It worked - and also the WP site opened to the home page... but bummer - the /pages in the WP site now no longer worked! But at least I know the source of the problem.
So I switched it back and this is the status quo - I have no idea how to fix this, and with everyone back at work tomorrow, clients are going to want to start downloading their stuff...
Can anyone help me? I'm starting to panic a bit
you only have to exclude the clients subfolder in your wordpress .htaccess - see .htaccess & Wordpress: Exclude folder from RewriteRule for a detailed description
this should work:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/clients.*
RewriteCond %{SERVER_NAME} !clients\.yourdomain\.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
short: it simply skips the wordpress rewrite rule if the reqest uri starts with /clients or the domain name is clients.yourdomain.com
be aware though, that as soon as you update your wordpress permalink settings, this rule will be overwritten by wordpress ...
Try adding the following at the top of your root directory's .htaccess file, before the WP code block:
<IfModule mod_rewrite.c>
# fix rewrite for GoDaddy
Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} clients.mwpics.com.au$ [NC,OR] # ignore subdomain
RewriteCond %{REQUEST_FILENAME} -d [NC] # ignore directories
RewriteRule .* - [L]
</IfModule>

Wordpress Permalinks Not Staying

At various points of the day my WP permalinks keep breaking. When I'm using custom perms it works but then a few times during the day it just throws a Page Not Found. I fix it by setting perms to default, then back to custom and it works fine.
My Sys Admin can't figure it out. Hopefully a guru can lend some help?
The problem is indeed most-likely the sCategory Permalink plug-in (the one that gives you /%scategory%/. 404s are somewhat common. Go to Options | Permalinks page in Site Admin and click Save Changes to regenerate permalinks. They way to confirm this is to use WP-default permalinks to test behavior. If all is working well, it is the sCategory Permalink.
If this isn't working, publish your .htaccess and that will help us troubleshoot better.
I'd be suspicious of something that is periodically overwriting your .htaccess file. When you set the permalink options, it updates .htaccess. If those settings are being "lost", there might be another piece of software running on your site that is mucking with the .htaccess file and removing or overriding the WordPress settings.
It seems that something else is automatically changing your htaccess file and overwriting the permalink settings.
What bvandrunen suggested may work. If not, you could set the permalink settings to what you want and then immediately change the permissions of the htaccess file to prevent anything from modifying it. I would suggest using chmod 644.
Naturally, a better solution still would be to find the script which is modding your htaccess file and get rid of it... but this fix should at least keep your permalinks working!
Do the creation/modification dates of .htaccess change or not? Even if you see no visible changes in .htaccess?
Permlinks are stored in the wp_options table in option_id 34 . Check them and then check after the change takes place.
Delete the existing Permalink structure and set it to default.
Delete the current .htaccess file.
Purge your site cache.
Write a new .htaccess file like #bvandrunen suggested.
Create your new permalink structure again.
That should work.
You can try using the 'try_files' directive in the Nginx configuration file for your website:
a) Open the configuration file present at ‘/etc/nginx/sites-enabled/yoursite.conf’ or ‘/etc/nginx/conf.d/default.conf’
b) Then add the following lines under the location / block:
try_files $uri $uri/ /index.php?$args;
c) It should look like:
location / {
root /var/www/html;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
You may also check out WordPress custom permalinks and Nginx for detailed information.
I would have to agree with #ahockley since I had this exact same problem with my WordPress blog. Which is happening is that the .htaccess file is getting overwritten and then when you set it to custom and then back to default it corrects itself for a while. What I had to do was something like this: (this is the default)
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Change to:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# BEGIN WordPress
# END WordPress
Once I moved the # BEGIN Wordpress out of the blocks the problem stopped. Hope this helps
.htaccess wasn't uploaded with my build!!!
A stupid mistake in my build process!
You may want to check server limits. We had this issue when MySQL was running out of space. When in your SSH, use
df -h
to list files and see if anything has run out of space

Resources