Editing .htaccess without FTP access through Wordpress - 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/

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.

Changing URL Wordpress- still not working despite checking/editing database

As much as may sound like a broken record - I changed the URLs on my WP site, and now I get a 404.
What I wanted to do:
Change site URL from www.SiteA.com to www.SiteB.com
All WP files were at the time in another directory in the same hosting account. I needed them in the root directory, accessible by www.SiteB.com
What I did:
Backed up locally and remotely - Database and files.
Edited URL's through dashboard on WP - got a login error afterward, but seemed to do it anyway.
Moed ALL old site files from root to backup folder.
Moed ALL wordpress files from original directory to root directory.
Then I got a 404 error and was unable to access WP-admin or login through the new or old URL.
What I tried to fix the issue:
Noticed http should be https - changed this in 'options' within phpmyadmin, both at 'siteurl' and in 'home'.
Still 404
Then I tried defining the db_name in the wp-config file.
Still 404
Then I gae up, changed the URL's back using myphpadmin, and moed the filed back to their original directory. Now I can login to WP as usual and eerything is fine.
Why can't I access the site when I moe it into the root directory - I thought I had all the steps right!
Thanks in adance for any help
oh..and apologies, my keyboard is missing a few keys :(
Wordpress stores url/permalinks on database field values as well, changing only the configuration files will not be enough.
I am pretty sure there are other options, on my case i use often perform Wordpress website migrations, and the following tool becomes really handy when search and replacing domains on the database records.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Hope it helps.
Jose
This happened to be an SSL issue where the host for our SSL certificate was conflicting with the stylesheet somehow. 0_o

My htaccess files keep changing on all my wordpress websites

I have two wordpress websites on my dedicated server, and the htaccess files of both websites keeps changing to default one and become 444 chmod.
Even after i fix it and put chmod 444 of mine few days later it changes again on both websites.
Could you please help me make the htaccess files impossible to be overwritten or edited no matter what?
I will appreciate any help,
Thank you
I find my infected file in one of the themes of wordpress, so you have two ways
LogIn to wordpress and delete all the new themes that you are not using.
Go to you your admin page go to folder: wp-content/themes/sydney/404.php
open it and if you see the virus code like if it has +xml or Rewrite wordpress etc delete it.
go through all the themes folder 404.php pages.
change your wp login user name and password.
delete all the infected .htaccess files/remove the infected code and monitor your website the regularly and check ur .htaccess file to make sure you don't get attacked again.
I have resolved this by scanning my ubuntu server using clamAv through SSH.
Here is the command line I used:
clamav -ril /home/user/clamav.txt
The results revealed a backdoor script embedded in one of my old themes which wasn't even activated. I deleted that old theme entirely and rebooted my server then the problem is gone.
Don't waste your time with a WordPress plugin to scan for malware or
backdoor because that is unlikely to locate any virus. Install ClamAV
into your server then scan. If nothing is detected yet?! Install
another anti similar to ClamAV until you succeed to locate the threat.

Wordpress - Moving website admin section

I have successfully moved a wordpress site from /test directory to the root, so now the website url looks like www.example.com. Fine.
However the admin section (wp-admin) still points to /test directory and so the url looks like www.example.com/test/wp-admin/...
How can I make it like www.example.com/wp-admin/...?
Please notice that I'm not interested in a simple redirection (now the customer is able to access the admin section with www.example.com/wp-admin, but then he's redirected to www.example.com/test/wp-admin/..., and it's not what he wants.
Thanks in advance
Everything is documented in http://codex.wordpress.org/Moving_WordPress
You may need to change many URLs in post/page content; if so, see https://github.com/interconnectit/Search-Replace-DB as suggested in the above Docs.
There is no need to create a new Wordpress install.
Also see http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install if you want to keep core Wordpress files and folders in a subfolder, but have the site appear to be at root for the end user.
You should not move wordpress this way. Here is what you do:
Install Clean Wordpress Installation on the new domain.
(www.original.com)
Use a plugin* to make back-up on your test domain.
(www.original.com/test/)
Install plugin* on the new domain, and restore back-up from test
domain. (www.orignal.com)
Update your style.css, header.php, index.php & footer.php if it
contains hard written links to your test domain.
You cannot simply move a wordpress installation - as most entries, links etc. are stored in the database. If you move folders in your ftp they will still point to the old database. This is why you have to duplicate your site, where the database entries will be automatically updated to your new site domain. Hard written links in any theme php files will have to be updated.
Although your problem depends on how your pointers/sites are set-up in c-panel. If you have to change pointers for your directory, you might have to back-up your website and upload it to a different domain so your new site can access the restoration back-up file via http request.
*Plugins such as wp clone, duplicator.

Clean URLs Broken after moving site to new host

I have copied an existing drupal 6 site to a new host. I thought it was an easy task. Just change the mysql login credentials and run. But obviously not. Fist page is up and runing, but all links to existing pages doesn't work.
What am I missing here? Another configuration I've missed.
The Drupal 6 installation is a NodeStream distibution.
Link to site:
http://u0002002.fsdata.se
It is likely that you forgot to set up mod_rewrite so the nice urls don't work.
It is almost certain mod_rewrite is not turned on you can access pages like this
http://u0002002.fsdata.se/?q=yrke-karriar
To resolve quickly:
Turn off clean urls (don't know the exact url in Drupal 6)
Flush all caches
This will resolve until you can get mod_rewrite turned on or working.
A very common (and even easier to fix) problem that happens when moving hosts is that you forget to include the .htaccess file which can cause problems with clean URLs too.
Fix: Upload a fresh copy of the .htaccess file that comes with Drupal to your web root directory.
I have found out that sometimes I miss this file. This is because I installed Drupal by dragging all the files and folders over to my server, but since the .htaccess file starts with a period, OS X hides it. This means that the .htaccess file was never moved over. - Source DrupalDude.com
And from Drupal.org directly, Clean URLs not working? Check your .htaccess file
Check if the .htaccess file was actually uploaded. It should be in the directory where you uploaded Drupal (for example: /public_html/drupal/)
If the .htaccess file is missing, you need to upload it. If you accidentally deleted this file, just download Drupal again, and copy the new .htaccess file.
Make sure the file is only called .htaccess and not htaccess.txt or anything else. The .period .at .the .beginning is required.
This name usually means that the file will be invisible on folder listings on Unix-based systems so you might not always see it. If using an FTP client, you may have to configure it to 'show hidden files'. If listing on the commandline, you must ls -la to see it. This will be somewhat dependent on your OS.
Here are two tutorials which may help you:
How to move a Drupal site from one host to another
How to Move a Drupal Site to a New Host Without Going Crazy

Resources