• Resolved Jeremy

    (@jfairbrass)


    Hi, I’ve been using the Root Relative URLs plugin on my new WP installation, and it’s exactly what I’ve been looking for.

    One thing I noticed, though, after I installed it, is that WP will no longer automatically redirect https://mydomain.com into https://www.mydomain.com when I type the former into my browser.

    On the General Settings tab I have both the WordPress and Site Address URLs set to https://www.mydomain.com. When this plugin is disabled or uninstalled, and someone types https://mydomain.com into their browser (without www), the URL will automagically change to https://www.mydomain.com as the page loads. This is what I want to happen. Also for the sake of SEO which, I’ve read, works better this way.

    But when the plugin is enabled, this automatic redirection doesn’t work anymore. Therefore my site is available at both URLs, which is not good.

    I had initially added the ‘WP_HOME’ and ‘WP_SITEURL’ definitions to my wp-config.php as instructed on the installation page. I then deleted them again, but doing so hasn’t fixed the above issue.

    Is there any way I can force WP to continue doing this www redirection even when the plugin is enabled? Perhaps something else I can add to wp-config.php?

    Better yet, it would be great if the plugin could be modified to offer this as an option, so that the administrator can turn on or off this functionality according to his needs.

    Thanks!

    https://www.ads-software.com/extend/plugins/root-relative-urls/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author MarcusPope

    (@marcuspope)

    Well Jeremy, you are correct that redirecting to the www (or non www) for SEO purposes is a good move. This is easily fixed in a .htaccess file so if I can’t figure out why my code is stopping this default WordPress behavior I can at least solve your problem.

    I’m still getting caught up on my support tickets but I’ll update this ticket when the problem is resolved or if I have any further questions for you.

    The wp-config variables are absolutely important to the proper function of my plugin so taking them out while leaving my plugin enabled is not recommeneded.

    Thanks,
    Marcus.

    Thread Starter Jeremy

    (@jfairbrass)

    Thanks Marcus, I appreciate you looking into this! I hope you’re able to figure out what’s going on.

    Plugin Author MarcusPope

    (@marcuspope)

    Ok Jeremy, so this is what I can do for now…

    If you put these lines in your .htaccess file at the root of your server:

    RewriteCond %{HTTP_HOST} ^domain\.tld$ [NC]
    RewriteRule ^(.*)$ https://www.domain.tld%{REQUEST_URI} [R=301,L]

    Be sure to change ‘domain’ and ‘tld’ to your actual site domain so for google.com it would look like this:

    RewriteCond %{HTTP_HOST} ^google\.com$ [NC]
    RewriteRule ^(.*)$ https://www.google.com%{REQUEST_URI} [R=301,L]

    That would solve your problem. I could add an admin feature so a user could specify they want this behavior (or the reverse to strip the www) but that would be a low priority for me at the moment. Let me know if this option works out for you or not.

    Thanks,
    Marcus

    Thread Starter Jeremy

    (@jfairbrass)

    Thanks Marcus! I’ve just added those lines to my .htaccess and they work for redirecting https://mydomain.com into https://www.mydomain.com.

    However, it doesn’t work for redirecting anything beneath that. Eg. if I enter https://mydomain.com/contact it won’t change that to https://www.mydomain.com/contact, although I need it to (also for SEO purposes).

    Do you know the correct entry to use in .htaccess to achieve that?

    I would still love to see this functionality built into your plugin directly – as an admin feature like you mentioned – so I don’t have to mess around with .htaccess, or remember to add it to .htaccess if I ever moved to a new host or something. That would be awesome, so I hope you will find the time to implement it at some stage in the future! ??

    Thanks again!

    Plugin Author MarcusPope

    (@marcuspope)

    Hey Jeremy, I’m not sure why that wouldn’t work. You may want to try the solution outlined here:

    https://stackoverflow.com/questions/4916222/htaccess-how-to-force-www-in-a-generic-way

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Root Relative URLs] www redirection is broken by this plugin’ is closed to new replies.