WordPress port removal gives 301 error

I have a wordpress website. In the website url section it automatically adds the port :80 at the end. It also adds the same port to every link on the website and to permalinks. This is a big issue for my employer because it is bad for SEO supposedly. Howevery, when I try to change the ‘example.com:80’ to just ‘example.com’ the website becomes unreachable with 301 error coming up. However, I am still able to log into wordpress admin section. So, is there a way to either remove ports from permalinks manually somewhere or if there is a way to change the website url so that it does not have the port in it.

http://example.com:80/sample-post/ – this is the example of the permalink

Read More

http://example.com/sample-post/ – this is what is desirable

Thank you

Related posts

2 comments

  1. In your wordpress settings, change the site url and wp url to your domain without :80. Port 80 is the default http port and so that is what your webserver listens on anyway (unless explicitly set up otherwise).

    Update

    Not sure about your exact setup, but here is what you should add to your .htaccess to redirect all requests to :80 explicitly.

    <IfModule mod_rewrite.c>
    RewriteEngine On    
    RewriteBase /    
    RewriteRule ^(.*)$ http://example.org:80/$1 [PT,L]
    </IfModule>
    

    Change example.org to your domain.

  2. Disable Canonical URL Redirection

    Drop the plugin into your wp-content/plugins directory and we will then need to activate it outside the admin area by fixing the database directly (I used Sequel Pro). Here’s how:

    1. Locate the wp_options table
    2. Set active_plugins to a:1:{i:0;s:31:”disable-canonical-redirects.php”;}
    3. Change the values of siteurl and home to / (might not be strictly necessary)
      http://localhost:8080/ should now work correctly.

    Just remember to disable/remove the plugin in production environment. The SQL values you just fudged would be correctly resaved once you have access to the admin section.

Comments are closed.