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.
Related
I've installed wordpress in multisite mode on my localhost. I am using WAMP server on windows 10.
The parent site works well and can be accessed. However when I try to go to the sub sites It says the URL was not found on the server. Both for the sites as well as their backends.
I have followed the network setup instructions as specified by wordpress.
I think it's an issue with mod_rewrite, how ever in my httpd.conf when I uncomment
#LoadModule rewrite_module modules/mod_rewrite.so
I get an internal server error
My htaccess file is
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase sandbox/mainsite/
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>
# END WordPress
Another curious thing is that when I change the permalinks in wordpress to custom structure and hit save, it does not get saved and reverts to the previous setting.
Any Ideas?
Ok Fixed the Issue.
The problem was the Rewrite Base was not reading the correct URL.
Adding a '/' before it worked. So I changed
RewriteBase sandbox/mainsite/
to
RewriteBase /sandbox/mainsite/
What I'm trying to do is server a subfolder: /subsites/brighton/ when the url domain.com/pop-up-in-brighton/availability is visited (that url is/can be a WP page. Doesn't matter to me). The site is build on wordpress so that domain is itself the result of an apache rewrite.
I've looked at RewriteRule examples and tried to adapt them but failed miserably. Can anyone help?
Whether it needs to be a rewriterule or maybe an alias? It's shared hosting so only really have access to the htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/pop-up-in-brighton/availability /subsites/brighton
RewriteRule . /index.php [L]
</IfModule>
Thanks!
i think what you need to check is the virtual server directive, you can create a new website with it's own folder and IP.
<VirtualHost 10.20.30.1:80>
ServerAdmin webmaster#host.example.com
DocumentRoot /www/docs/host.example.com
ServerName host.example.com
ErrorLog logs/host.example.com-error_log
TransferLog logs/host.example.com-access_log
</VirtualHost>
Virtual server directive
also check this article about virtual hosts and .htaccess
.htacess and VH
You need to install wordpress in your sub directory /subsites/brighton and you can follow these instructions for using a sub directory.
http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
Then you can point to that directory from /pop-up-in-brighton/availability using mod_rewrite in the .htaccess of you root directory.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com$
RewriteCond %{REQUEST_URI} ^/pop-up-in-brighton/availability [NC]
RewriteRule ^(.*)/?$ /subsites/brigton [L]
See how that works. Replace yourdomain with your real domain.
I have a laravel installation at same domain.com. The site is up and running. I need to install a wordpress in blog folder at domain.com/blog. when I try to install the wordpress, it's not allowing me to run the installation and says "This webpage has a redirect loop" . I installed wordpress by using domain.com/blog/index.php, But after installation I was not able to run the wordpress blog from domain.com/blog/
I have provided relevant permissions to the wordpress blog folder.I will be managing wordpress from the blog admin and laravel site from laravel section.
I have seen https://laracasts.com/discuss/channels/general-discussion/install-wordpress-in-domaincomblog but could not make it work.
Mu working environment is : Xampp in Ubuntu
Any suggestions will be helpful.
I got a solution from laravel forum. Adding the line in the htaccess worked for me.
RewriteCond $1 !^(blog)
Blog is working properly as a separate folder.
this line in .htaccess is probably your culprit:
RewriteRule .*/$ /$1 [L,R=301]
comment it out and see it that solves your problem.
This line forces everything in the public domain to go through laravel's router. You could probably leave it by writing another regex above that line looking specifically for the /blog directory, or rewrite that line to route anything that != your blog directory.
You should really leave that line there if possible.
Add below lines in .htaccess
RewriteCond $1 !^(bmcblog)
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
It will look like this
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond $1 !^(bmcblog)
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
This SO article about loading files from a remote site when they don't exist locally provides .htaccess RewriteConds and RewriteRules to achieve the task.
I also want to use this on my WordPress site so I thought these instructions would be perfect for me, but they're not working. I'm using WordPress 3.9.1 running on MAMP PRO 2.0
I structure URLs for my local sites as; local.domain.com so I alter the patters from the original SO article to the following
# Use remote uploads when they don't exist locally
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^local\.domain\.com$
RewriteRule ^.*/(uploads/.*)$ http://domain.com/wp-content/$1 [L,R=301,NC]
</IfModule>
The original SO article is not clear on where this .htaccess file should be placed. I tried it in the WordPress root directory, and /wp-content/uploads/ without success.
Any ideas what I'm doing wrong would be appreciated.
Try this rule in /wp-content/uploads/.htaccess:
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^local\.domain\.com$
RewriteRule ^(.+)$ http://domain.com/wp-content/uploads/$1 [L,R=301,NE]
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%/