Problems with Drupal 7's clean URLs - drupal

I've looked around and I couldn't find an answer to my question so here it is.
Clean URLs are enabled on my Drupal 7 website and are "working" in the sense that I can access the About Us page with www.mysite.com/about-us and with www.mysite.com/node/12.
However, usually with Wordpress and the get_permalink() function, every menu/links like ?p=12 get redirected/rewritten to /about-us. But with Drupal, my menu links are in the form node/12 , and when I click on a link I get the page /node/12, not /about-us.
Any idea how I can get the rewriting/re-routing done automatically?
Thanks!

Your best bet would be the Global redirect module. The first of its many functions is:
Checks the current URL for an alias and does a 301 redirect to it if it is not being used.
I've used it in just about every Drupal site I've ever made and it works well.

Related

wordpress delivers wrong page

Currently running WordPress 4.9.5 using the Divi theme with Permalinks set to use Post name, I can enter a url (page title/name) that does not exist on the site and WordPress will deliver a page that has the “filename” part of the url somewhere in the title/name of the page it delivers but is different than the actual url.
For example, if you go to http://space.nss.org/renew/
Instead of getting a 404, WordPress delivers the page http://space.nss.org/renewable-energy-partnership/
What on Earth is WordPress thinking?
What can I do to identify the exact nature of the problem and fix it?
Note that this behavior is not universal as I can enter bad urls (like space.nss.org/armstrong/) and do get the expected error page.
Thanks in advance, Jim.
NOTE: The url referenced above (space.nss.org/renew/) has now been fixed so its original behavior is no longer exhibited.
With respect to my problem, it turns out that Wordpress is just trying to help by assuming that humans do not know how to type.
When I type "space.nss.org/renew/" and Wordpress doesn't find an exact match, it looks for anything it can find containing the string "renew"
and delivers what it considers to be the best match as a way of avoiding delivering a 404 page to the visitor.
This feature can be turned off but there are consequences in that the 'redirect_canonical' is also responsible for resolving domain name issues (like www.domain.com vs domain.com). For reference, see https://codex.wordpress.org/Function_Reference/redirect_canonical
Following are references on the subject I found once I knew what I was looking for.
[https://wordpress.stackexchange.com/questions/3326/301-redirect-instead-of-404-when-url-is-a-prefix-of-a-post-or-page-name]
2
[https://serverfault.com/questions/776310/how-to-disable-the-automatic-redirection-in-wordpress-htaccess-file]
3
[http://biostall.com/prevent-wordpress-redirecting-to-nearest-matching-url/]
Looking at the network log it appears there is a 301 redirect placed on /renew to go to /renewable-energy-partnership
As a solution you could remove the redirect so that it goes to the 404 page instead.

Why does WordPress allow multiple page-slugs in url without triggering 404?

The title is pretty self explanatory, but I'm trying to figure out why WordPress allows this or if it's a setting in .htaccess perhaps, but here's the example:
I have a page, lets say a "Contact" page with the slug of "contact-us".
I go to http://example.com/contact-us/ -- everything works normally
I go to http://example.com/contact-us/contact-us/contact-us/contact-us/contact-us/contact-us (I could do this a million times) and it does NOT trigger a 404 error!
Why is this? If I enter a random string of numbers, it instantly triggers 404.php, but just repeating the page-slug does not trigger a 404.
I would like the page-slug to not be able to be repeated over and over again and trigger a 404 if it even gets repeated once.
Has anyone else experienced this issue? Is it possibly a canonical link issue or a "nofollow". I just don't understand why WordPress is not seeing this as 404 material.
Thanks in advance for any replies, suggestions, and help.
I have found a way to solve my own problem. Today I noticed that I was running two WordPress builds on the same server but one went to 404 while the other would just go back to the page. Now I knew it was a theme specific issue.
The answer is really simple actually, it was a permalink issue. In order for me to get the behavior I was looking for, I had to select "Post Name" as my permalink settings.
I previously had a custom string of options for a different style display using "Custom Structure", which I'm assuming had the "failsafe" in it.
I'm willing to switch out the extra permalink styling options in favor of the 404.
Although, those that opt to use a custom permalink structure should see if this happens to you.

Wordpress Page - I need to GET variables

I am not a wordpress guy and a client needs me to modify some pages. Someone else has created the entire site in wordpress.
I am having trouble with a query string that contains variables.
wordpresssite.com/pages-using-template/?variable=something
This causes the page to get thrown to the default 404 for the site..
Any suggestions on which file i need to fix this in and how to do it?
Thanks
wordpresssite.com/pages-using-template/?variable=something
That's giving you a 404 error, probably because you're trying to add the query string variable to the home page of the site. There's no "file" that fixes this - WordPress is dynamic. the .htaccess rules handle the URL rewrites ("pretty permalinks")
So I guess you need to give more information on what it is you're trying to do. There's not going to really be a way to "fix" the URL without breaking the rest of the site (it's possible, but I'm betting that whatever it is you're trying to do requires a much simpler solution).
What query string are you trying to add in? For what reason?
For example, I recently did a WordPress site from someone who needed a directory on one page of the site, that had a custom search from in it. I created a function that would $_GET the URL of the page and add the search query to it, and then return the end user to the page with the results there.
You also have to be careful about the $_GET in your functions - you want to be sure they're protected against injection attacks by using $wpdb->escape($_GET['xxx']).

How difficult it is to redirect broken links based on keyword matching?

I currently host a blog on blogger under my own domain. The problem with blogger is that one cannot change the URLs. Page URLs contain "/p/", blog post URLs contain date (which don't even have to correspond to the actual publication date). If at some point I were to move to a self hosted solution and change the URL structure to something more user friendly, how would I redirect the broken links to new URLs, based on extracting the keywords from the old link? Does ASP.NET MVC offer an easy way to implement that?
I ask because I would like to stay with blogger for a little more, but wouldn't like to pay the price in the future.
Check out IIS Url Rewrite: http://www.iis.net/download/urlrewrite

Is this possible to give different links for the same wordpress blog?

I have developed a site using wordpress. I have two main links in the site e.g. www.mysite.com/siteone and www.mysite.com/sitetwo and I have managed only one blog contents. Now what I need to do is that I want to link the same blog with different link like this:
www.mysite.com/siteone/blog and www.mysite.com/sitetwo/blog and also need to have same content for links www.mysite.com/siteone/blog-1 and www.mysite.com/sitetwo/blog-1. Is it possible to do so, if yes then how to do that? If not then what can I do for that?
Thanks in advance
From the SEO perspective, it's wise to use canonical tag. This tag was a new construct designed explicitly for purposes of identifying and
dealing with duplicate content. Implementation is very simple and looks like this:
<link rel="canonical" href="http://www.yoursite.org/blog" />
This tag is meant to tell Yahoo!, Bing, and Google that the page in question should be treated
as though it were a copy of the URL http://www.yoursite.org/blog and that all of the link and
content metrics the engines apply should technically flow back to that URL.
The canonical URL tag attribute is similar in many ways to a 301 redirect from an SEO
perspective. In essence, you’re telling the engines that multiple pages should be considered as
one (which a 301 does), without actually redirecting visitors to the new URL (often saving
your development staff trouble).
link
The "home" link in a WordPress installation is determined by an option in the database called siteurl, so in theory you'll just have to use the same database on both blogs and override the siteurl on the two to make it seem like two different websites.
A good way to start from is define a constant in your wp-config.php, which should be different for both websites:
define( 'MY_SITE_URL', 'http://yoursite.com/siteone/blog' );
And then write a single-line plugin that would simply add a filter to the get_option call for siteurl. Something like this:
add_filter( 'option_siteurl', create_function( '$value', 'return MY_SITE_URL;' ) );
That's only the start, and if that works for you you'll have to then rumble around your wp-content directory to make sure they are in sync for both websites, i.e. after uploading an image to one blog you'll need to copy the file into the other one.
I did manage to get two different websites working under one WordPress installation using two different databases, but having two WordPress installations working line one site under two different domains, that's tricky ;)
~ K

Resources