Wordpress doesn't update htaccess after change Site Address - wordpress

how are you doing?
I need some assistance in a huge problem that I tried to solve in many ways and I could not.
I have two separated servers one answering by this url www.mysite.com and another by blog.mysite.com.
The server one aka Site (www.mysite.com) there is a proxy to server two aka Blog (blog.mysite.com).
.htaccess
RewriteRule ^blog/?(.*) http://blog.mysite.com/$1 [P]
The wordpress is installed in the Blog server. When I change the Site URL to responde by www.mysite.com/blog the file .htaccess does not update anymore.
For instance:
I get this Error:
And on W3TC:
So, if I put the Site Address equal to WordPress Address the .htaccess update without problems.
PS: This is not a File Permission problem, the permissions are ok. The user/group are correct.

Wordpress don't have a permission for editing .htaccess.
There're 2 solutions:
".htaccess" file should have same user/group owner with PHP (for example, www-data).
You should give write permissions to ".htaccess." In this case give CHMOD 666 permission for ".htaccess" file.

Related

Wordpress website cannot be found after accidentally changing site URL

I changed my Wordpress website site URL prematurely and now it tells me Not found The Requested URL was not found on this server. I've been struggling with this and trying to find a fix but everything I've done has not fixed it. I've gone into the config file to update the URL, define the URL, you name it, I've done it. So I'm pretty desperate at this point and any help would be appreciated.
P.s I'm also running the server off of a Digital Ocean droplet. So I haven't been able to access the DB through MyPhpAdmin.
Thank you!
To change the WordPress site URL you need to do it manually as you can’t do it from your WordPress admin panel. There are two ways to do that:
Method 1 - Change WordPress site URL by editing wp-config.php file. This is the easiest way;
Add the following code to the end of wp-config.php file and save the file.
define('WP_SITEURL', 'http://www.example.com');
define('WP_HOME', ' http://www.example.com');
*Change www.example.com with your site domain.
Method 2 -
Please try to change the URL from PHP MY ADMIN > select your database > goto wp_options and change the URL
Using FTP/ SFTP , or your web-host’s cPanel or whatever file management application your host provides, access phpMyAdmin on your host, then find your DB, there check the wp_options Table (Note: The table prefix of wp_ may be different if you changed it when installing), and make sure site URL field and home field are correct.
I found the fix!!
When the site URL changed so did the root directory. The root directory added another folder to the path. So it looked something like this var/www/html.old/html.
Apache was still trying to access the site through var/www/html.
So I adjusted the file path and boom! Apache was able to make the connection and the website is now showing.
To get to the apache folder it was /etc/apache2/site-available/. I was then able to nano into the 000-default.conf file and adjust the file path through there.

Wordpress Directory Switch Issues

I recently set up a digitalocean account with wordpress pre-installed. When it is pre-installed, the directory structure begins in the root (var/www/html/). I wanted to change this, so i moved the files into a new directory (/var/www/html/viralnewz) and changed the wp-config files to represent this (they no longer point to the http://178.62.87.202/ but instead to viralnewz.co.uk, which in turn will point to viral newz directory (/var/www/html/viralnewz). This is set up with a virtualhost, and works fine for the front-page and the admin. But when i try and view others pages, i get a 404 not found. I'm assuming theres an issue with the wordpress setup because it can't find the correct page, however i'm unclear how to actually solve this issue.
Apache conf file
<VirtualHost *:80>
DocumentRoot /var/www/html/viralNewz/
ServerName viralnewz.co.uk
# Other directives here
</VirtualHost>
Additionals to wp-config.php
define('WP_HOME','http://viralnewz.co.uk/');
define('WP_SITEURL','http://viralnewz.co.uk/');
If i've missed any other information that could be beneficial, please mention it and i'll do my best to find it.
Chris
I think your problem can be related to url values stored in DB.
You can migrate safely using this tool, that permit to find and replace the urls stored in DB.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Can be also necessary update .htacess file: normally is enough enter in permalink settings and save again the structure of permalinks.

Editing .htaccess without FTP access through Wordpress

I have no access to my FTP but I'm able to edit the web through Wordpress. Is there any way I could perhaps generate the .htaccess file through the admin framework? I know there might be a plugin to do that, but bear in mind I have no FTP access and the plugins require it to be installed.
I need the .htaccess file to redirect the user to another site.
I know this might strike you as weird and stupid, but this is due to the company's central decision to keep the site hosted by, I guess, a "friendly" hosting company. There's no way of recovering the login/password for FTP, so this might be the only solution.
Please, try posting constructive comments only, no "contact the hosting company". If I could, I would.
If your hosting company has set up wordpress correctly, then there is no way to do this, because unix permissions should make .htaccess read-only to the owner of the web server.
If the company has not done this, and if you have a way to change the templates, you might have success by creating a template that contains php code to open and write the .htaccess file.
Sample code to be put at the top of the header.php:
echo 'Current dir: ',getcwd(),"<br>\n";
if ($handle=opendir('.')) {
while (($file=readdir($handle))!==false) {
$ok=(is_writable($file) ? "ok" : "can't write");
echo "file '$file': $ok<br>\n";
}
closedir($handle);
}
This is to test you're in the root directory of your wordpress installation. It should give you the current directory, a list of all files in that directory (expect .htaccess, index.php, and various wp-* files), and their writability.
Once you've checked everything is correct, add
file_put_contents('.test', "RewriteEngine On\nRewriteRule ^(.*)$ site.com$1 [R=301,QSA,L]\n");
echo("<code><pre>-------- included file starts here\n");
include(".test");
echo("-------- included file ends here</pre></code>\n");
to the php code. This writes to a test file and includes it so you can check if everything is ok. When you've checked the file contents, replace .test with .htaccess.
WARNING: You should be VERY sure about the content of .htaccess. file_put_contents doesn't append the new string, it overwrites the whole file. Once you've written a bad .htaccess file, you might not be able to ever change it again, because the web server will redirect you to the new site instead of executing the script on the old site.
I am sorry for your situation. What is the hosting company (will keep this in mind if I ever use them). To try to help:
Do you have access to CPanel? Most hosting providers give it out of the box. Cpanel has a file manager.
Research Wordpress file managers (http://wordpress.org/plugins/wp-filemanager/)
How to edit wordpress .htaccess file from hosting Cpanel: If you are currently unable to login in your wordpress dashboard, or facing 500 internal server error. There is 90% possibility that you were editing your .htaccess file from your wordpress dashboard. In this situation you can only fix your wordpress .htaccess file by editing it from cpanel. Editing .htaccess file from wordpress dashboard is little risky with .htaccess editor plugins. If you will implement any wrong code then you might face 500 internal server error and your site might crush. So first you should take a backup of your existing .htaccess file before editing it. If you have a backup of your wordpress .htaccess file then you can upload it through your hosting cpanel also.
https://howtoways.com/how-to-edit-wordpress-htaccess-file-from-hosting-cpanel/

Wordpress Forbidden Update Pages

I already tried to look for some solutions about this, but i didn't find any.. Maybe you guys can solve my problem.
I can't update my Wordpress page
Forbidden
You don't have permission to access /demo/myfolder/wp-admin/post.php on this server.
Apache Server at www.my-site.com Port 80
some say to delete my .htaccess file and refresh the page. that didn't work..
Right now here's the content of my .htaccess file
# BEGIN WordPress
# END WordPress
I also tried "wp-admin and right click on the very folder, give permission 777"
Internal Server Error File "/var/www/vhosts/my-site.com/httpdocs/demo/myfolder/wp-admin/post.php" is writeable by group suPHP 0.7.1
Thanks
If you have ftp access go to wp-admin and right click on the very folder, give permission 777 (if you are using Filezilla).
777 permissions are unnecessary and very insecure. See the docs at WordPress.org Changing File Permissions « WordPress Codex for the correct file/folder permission structures and how to change them with an FTP client.
If that doesn't work, ask your webhost.

Wordpress permalinks broken

I have recently moved my blog from one serever to another. I am now unable to restore my permalink structure.
Now my permalink strucure has become /?p=123. Whenever, I try to change it to any other custom permalink structure, it throws 404 for all the posts. Check the blog at http://microreviews.org
I have been forced to make the permalink structure as /?p=123. All the entries from search engines are however on the old structure /%postname%/
None of the plugins for the same seem to work and I am stuck with the ?p=123 structure.
What should I do?
Assuming you're on Apache server:
You don't have the .htaccess file on the new server, or
the new server doesn't have mod_rewrite turned on, or
the new server ignores the .htaccess files, or
any combination of the above :)
The other option instead of using .htaccess (although Wordpress is built around modifying that file) you can take the contents of the .htaccess file and add them to a directive in your httpd.conf (or virtual host config file). This approach requires more access to your apache installation (i.e. it might not work with some hosting solutions), but according to the Apache httpd documentation it's more secure and less work on the server since apache will scan every directory for .htaccess files each time a page is accessed and it will re-load the .htaccess file(s) every time the page is accessed as well. If the access is put into the server config then it is loaded once at apache start-up (or on a server reload) and that's it.
For example:
If your .htaccess file contained the following for the /www/htdocs/example directory
AddType text/example .exm
Then the following in your httpd.conf file would be equivalent
<Directory /www/htdocs/example>
AddType text/example .exm
</Directory>
The approach of editing your main configuration instead of .htaccess does not require that you specify AllowOverride to something other than None.
In this case, you'll still need mod_rewrite enabled for permalinks to work correctly.

Resources