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%/
Related
Synology Server with DSM 7.1.x (recently updated from DSM 6.x and downgrading back down to DSM 6.x is not recommended by Synology)
Webstation Enabled with HTTP back-end server: Apache HTTP Server 2.4 and PHP:
PHP 8.0
Personal Websites with these settings HTTP back-end server: Apache HTTP Server 2.4 and
PHP: PHP 7.4
Personal Websites use WordPress 5.x or 6.x which require a .htaccess file
Problem: Personal Website .htaccess in /homes/user/www folders causes the 403 error
Could delete .htaccess to stop 403 error but Personal Websites use WordPress which requires .htaccess - cannot just delete this file because some WordPress actions recreates the .htaccess file (such as changing Settings > Permalinks)
Newly created test user case: tmp
homes/tmp/www folder has "users" group with 775 permissions
homes/tmp/www/.htaccess has owner of "username" and group of "users" with 770 permissions
homes/tmp/www/wp-config.php has owner of "username" and group of "users" with 770 permissions
Even with permissions of 777 for ALL files in homes/tmp/www, the 403 error still exists with .htaccess
After deleting the .htaccess and creating/publishing a new page, viewing the new page results in a 404 error.
Default .htaccess lines
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /~username/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~username/index.php [L]
</IfModule>
Even if .htaccess has no lines of code at all, the 403 error exists. So just the existence of the .htaccess file regardless of content causes a 403 error.
Anyone have ideas to solve this problem?
Solution I stumbled upon:
Edit the httpd2x.conf for Apache2.x (whichever is chosen for Personal Websites)
Add the following code
UserDir www
<Directory "var/services/homes/*/www">
Options FollowSymLinks
AllowOverride All
</Directory>
I tried a bunch of stuff and I think the above was the trick.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /~username/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~username/index.php [L]
</IfModule>
It looks like you are using Apache per-user web directories? If that's the case then /~username is not a physical directory (it's an "alias" to your user directory) and your document root is effectively /~username/ (which really messes with root-relative URL-paths).
In which case, your .htaccess should be like this instead:
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
Note that I've removed the RewriteBase directive altogether.
However, if this is part of the WordPress code block (ie. inside # BEGIN WordPress ... # END WordPress) comment markers then WordPress is going to try and overwrite your changes unless you take additional steps to prevent this.
I have WordPress installed in the root folder and in a subfolder. I can access the home page for the WordPress site in the subdomain, but the permalinks does not work – error 404. I have tried to reset the permalinks, but it did not help. I can’t find any .htaccess file, so I have created one myself and placed it in the subfolder directory:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projects/bigsargefitness/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /projects/bigsargefitness/index.php [L]
</IfModule>
Here is a link to the subfolder WordPress site:
http://ninahortendesigns.com/projects/bigsargefitness/
I have set the database options to the above direction.
Thanks for your help.
You will need to look at a few things:
.htaccess file in the root WP site (WP1) and edit it so that WP1 doesn't catch the URLs and generate 404 errors, I'm not sure if that comment assisted, I've used this answer for a similar issue.
.htaccess file in the sub WP site (WP2) and rename it to "htaccess.old" then log into your wp2/wp-admin, go to "Settings->Permalinks" check the URL structure is as desired (it doesn't usually change) and click "Save" at the bottom of the page. This will regenerate your .htaccess file within the context of the sub-directory and you shouldn't get 404 errors when you visit sub-pages like this
Here's the code from the first link edited so that it should work with your site, although if you have additional rules, you should only insert the line under the comment.
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
# Include in the next line all folders to exclude
RewriteCond %{REQUEST_URI} !(projects) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
If you have custom rules, only insert these lines
# Include in the next line all folders to exclude
RewriteCond %{REQUEST_URI} !(projects) [NC]
Assuming you're a designer and are uploading examples of sites you've built, you should only have to do step 2 the next time you upload a new site to the wp1/projects/ sub-directory
Cause
Error 404 occurs when the resource or path you requested cannot be reached. In this case it's likely because URL rewrite isn't working properly, hence the permalink requests were still being directed to the requested path (e.g. /projects/bigsargefitness/your-category/your-post-name) instead of the rewritten path (i.e. /projects/bigsargefitness/index.php).
The following solution assumes you use Debian/Ubuntu, otherwise the principles should remain the same.
Solution
Firstly, ensure that the rewrite engine has been installed:
sudo a2enmod rewrite
Then, ensure that the engine is allowed for the subdirectory by editing/adding the following lines in the file /etc/apache2/sites-available/your-site.conf:
<Directory /var/www/projects/bigsargefitness/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
The key here is to ensure that the line says AllowOverride All instead of AllowOverride None.
Finally, restart your server:
sudo service apache2 restart
Let me know if this helps.
I just moved a Wordpress site to new host. But when I go to any page except the HOME page, I got this error:
Not Found
The requested URL /about was not found on this server.
Apache/2.2.16 (Debian) Server at 176.xx.yy.zz Port 80
I changed the Permalink setting to Default which make the URL looks like mysite.com/?page_id=5 and the page shows up fine. So the problem is not in my code.
My first guess is mod_rewrite isn't enabled. But phpinfo() tells me that mod_rewrite is loaded properly.
My .htaccess is generated automatically and looks like:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /beta-test/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /beta-test/index.php [L]
</IfModule>
# END WordPress
Any solution?
Thanks
You need to edit your Apache http.conf file and
change #LoadModule rewrite_module modules/mod_rewrite.so
to LoadModule rewrite_module modules/mod_rewrite.so
On versions of Apache2 where http.conf is no longer present (i.e. ubuntu) you can use the command a2enmod rewrite to enable the module.
Assuming your .htaccess file is in place, this is most likely caused by the Apache rewrite module not being enabled on your new server. On Ubuntu do this:
sudo a2enmod rewrite
sudo apache2ctl restart
I believe this could be because of these three issues also.
AccessFileName .htaccess is commented in your apache config.
AllowOverride ALL is not mentioned in your apache config for wordpress path.
This might be a problem with the paths defined in the rewrite rule
Consider changing the following in the rewrite rules in the .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 worked for me.
This is simple, run:
shell > a2enmod rewrite enable
If you are running on apache2.
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
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.