htaccess redirects to blank page - wordpress

Recently my wordpress website was hacked, and mobiles were redirected to an unsavoury site. I didn't have any previous knowledge of .htaccess, but I'd read that the culprit would be there. And it was, so I deleted everything in the .htaccess file. But it stopped working entirely, so I found this generic wordpress redirect code. The code is
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
It works fine now when viewed from a desktop machine, but whenever it is viewed from a mobile device it redirects to a blank page.
Any ideas?

It sounds like there was probably a specific mobile redirect rule in your old .htaccess file, which has now been erased and/or there is some specific WordPress code that handels the redirect.
Ideally, you would restore your files from a backup. But if you don't have a backup, you'll have to do some sleuthing.
I am not particularly familiar with WordPress, but I suspect you probably installed a WordPress plugin in order to get the mobile-specific functionality or redirect. If that's the case, you should either reinstall it or reach out to the maintainers of that plug in.
Otherwise, you can find a variety of different Apache redirect snippets for redirecting mobile devices - some Googling would probably help you find what you need.

Related

Redirect old subdirectory page requests under a new Wordpress installation

Our site was recently migrated from a basic php/mysql app to Wordpress. In the old app, we had content in a subdirectory which is now located on a new domain.
Examples below.
Old link:
https://example.com/vibes/vibin.php?showsomething=abcd&whatever=whatever
Should redirect to:
https://vibes.com/vibin.php?showsomething=abcd&whatever=whatever
The complicated angle is that the Old links are now a Wordpress installation. In the default .htaccess file of wordpress I see the following:
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I've poked around in the WP admin area but don't see how I'd safely edit that file.
Is there another way around this or are will our users just have to update bookmarks the old way?
htacess
You can edit the .htaccess file by hand using ftp and add the redirect that you want. Make a backup first. If you want to avoid ftp access then I don't recommend updating the .htaccess file at all because you'll need that access if you break something.
You could use a WordPress plugin to edit the .htaccess file to avoid ftp access, like "Htaccess File Editor." (Please make sure you have ftp access before you try this so you can put your backup back into place if it breaks.)
If you want to redirect all requests then I would look here https://serverfault.com/a/280067 to see how to create a redirect using .htacess that redirects to another domain and also keeps the query string. Maybe it would look something like this.
RewriteCond %{HTTP_HOST} !^vibes\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) http://www.vibes.com/$1 [L,R,NE,QSA]
If you want to only redirect requests to a certain URL on the old site, then I would look here https://stackoverflow.com/a/8416095/222564. Maybe it would look something like this.
RewriteBase /
RewriteRule ^vibes/(.*)$ http://www.vibes.com/$1 [L,R=301,QSA]
plugins
Since the old website is running WordPress, instead of editing .htacess you could use a plugin to redirect requests. There are various "redirect" plugins available. For example "404 Solution" has an option to redirect requests based on a regular expression to another domain and keep the query string. I maintain that plugin so I know it does that, but I don't know about the other plugins.
For example you would redirect from /vibes/(.*) to http://www.vibes.com/$1

avoide landing page redirect in wordpress with htaccess

I am getting the following from google page speed tool
"Avoid landing page redirects.
Your page has 2 redirects. Redirects introduce additional delays before the page can be loaded.
Avoid landing page redirects for the following chain of redirected URLs."
http://example.com/
https://example.com/
https://www.example.com/
Is there any way to avoid the redirects?
i am using wordpress. i have tried different rewrite rule but they are not working.
my htaccess right now is below
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
if you want try this
Edit wp-config.php
It is possible to set the site URL manually in the wp-config.php file.
Add these two lines to your wp-config.php, where "example.com" is the correct location of your site.
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
If you have any ssh plugin, try to stop it from redirect
Well, There could be other plugins doing such redirection.
Please disable all plugins and try.
If 1 does not help, then remove all content from your htaccess file and re-save permalink option from wp-admin panel.
Hope any of the above step may help you.
rony2k6 had said to disable the plugins. This is a good idea. If you disable the plugins. Then you enable one you check if you have redirects, then you enable the next you check again, and you repeat the procedure. You are going to find which is the plugin that produce redirects. Then you are goin to ebable all , but not the one with the problem. You must see why it produce the problem is it a not good setting or you must use another similar plugin

Wordpress serving every page and files as homepage

I have a wordpress install that is a multisite setup and the site has a DNS pointing to it.
Both the site and home URLs have been changed to the domain.
If i visit the site all the javascript and css files are served as the homepage HTML so everything is broken. Also if you click on any link it delivers the homepage and not the requested page.
I have tried changing the theme to twenty seventeen and disabling all the plugins, but the problem persist.
Any help or direction would be greatly appreciated.
Update:
I moved the site to a subdirectory and changed back to a single site, so now the site is almost a direct clone from its original host, but the problem with every page loading the homepage still persists.
here is the htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdirectory/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdirectory/index.php [L]
</IfModule>
# END WordPress
Update 2:
Digging deeper i found that every page has empty query vars which is why its only loading the home page.
add_filter('request', 'overwrite_query', 10, 1);
function overwrite_query($q){
var_dump($query);
}
returns
array(0) {}
Have you tried deleting the htaccess file and trying a new one? I think WP will create one if it doesn't find one.
Please open wp-admin page (Wordpress back-end page) then update permalink. then after work perfectly javascript and css.

WordPress: Non-existent pages are being loaded

I believe a hacker modified the website 'http://bbltechnical.co.uk/' so that loads of dating website show up in Google search results for the website. I have looked for those posts/pages via the dashboard and database, and the don't seem to be anywhere.
(I warn further click-through links on the following page contain explicit content)
Example spam page: http://bbltechnical.co.uk/online-uk-dating/
You can see I have changed the theme of the actual website, yet the theme hasn't changed on the spam pages. Using Wappalyzer I have found the WordPress versions differ. Also the two images in the body text of that page do not exist on the FTP. So I have concluded it is another WordPress set up, sharing the same domain name.
I have cleared the database, flushed out the DNS records, and even spoken to GoDaddy about it. It is such a weird behaviour.
This is 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
I found it was a modification of 'wp-blog-header.php', at the root of the site, which edited the HTTP header to pull in data from another website.
I used a malware scanner plugin to scan for any changes to the core WordPress files.
Thanks to uvishere's suggestion, I used the plugin 'Sucuri Security' to scan for the changes. Another option is the plugin 'Wordfence'.

404 error transferring wordpress website from local server

I've transferred my wordpress website from my localserver to a folder on my server. It is located in /wordpress. I have created a new database, new user and password and imported. I have also changed the location and home of the website in wp-options. I have changed the wp-config file. I'm still getting a 404 error. I then tried removing all the files, adding a clean install of wordpress then added my theme but still the same error. I can't even access admin or install. Can someone talk a look and tell me what I've done wrong? I have done this before and it normally works fine. Could it be the hosting?
See website here
I've check my .htaccess file and it says the following:
# 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
Check you're .htaccess file. I had this exact same issue the other day. Because it's in a subdirectory, it's keeping track of that in the .htaccess file, and I'm going to guess the subdirectory on the server is named differently than what it was on your development environment :)
Check you're .htaccess file and if you dont want to do coding in htaccess file.
Then login to wp-admin and go to the permalink section and hit update button
Hope it will solve the problem
Thanks
First of all remove .htaccess file and login in wordpress to run normally, lets check to conform this error due to .htaccess file.
Hope this helps you. Thanks ;)

Resources