WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] drop WWW to fix domain.com redirect signup.php (5 posts)

  1. pyroboy024911
    Member
    Posted 1 year ago #

    So few weeks ago i set up a site and finally got godaddy to work with subdomains but since i built the site using http://www.domain.com rather then domain.com like your supposed to im running into the problem of domain.com redirects to domain.com/wp-signup.php? is there a way to remove the "www" to fix this issue

    ive tried the define( 'NOBLOGREDIRECT', 'www.domain.com' ); which worked but then i ran into the problem with 404's not being called when ended.

    i also tried

    # Redirect non-www urls to www
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]

    this did not work no matter where i placed this in my htaccess file...

    so my only solutions has been to add this function

    function ms_block_wp_signup() {
    if( strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php' ) !== false ) {
    wp_redirect( get_option('siteurl') );
    die;
    }
    }
    add_action('wp', 'ms_block_wp_signup', 99);

    but this add a full two seconds to page load times and im worried about this not being SEO friendly being a simple redirect rather then a 301

    im kind of in need of some assistance im really banging my head on this one.

    here is my htaccess file as is today.

    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    
    RewriteEngine On
    
    RewriteBase /
    
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    
    RewriteCond %{REQUEST_FILENAME} -d
    
    RewriteRule ^ - [L]
    
    RewriteRule ^(wp-(content|admin|includes).*) garagedoorsolutionstx/$1 [L]
    
    RewriteRule ^(.*\.php)$ garagedoorsolutionstx/$1 [L]
    
    RewriteRule . index.php [L]
    
    </IfModule>
    
    # END WordPress
    
    # Redirect non-www urls to www
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    
    # BEGIN wtwp_cache
    
    <IfModule mod_mime.c>
    
    	# Text
    
    	AddType text/css .css
    
    	AddType application/x-javascript .js
    
    	AddType text/html .html .htm
    
    	AddType text/richtext .rtf .rtx
    
    	AddType text/plain .txt
    
    	AddType text/xml .xml
    
    	# Image
    
    	AddType image/gif .gif
    
    	AddType image/x-icon .ico
    
    	AddType image/jpeg .jpg .jpeg .jpe
    
    	AddType image/png .png
    
    	AddType image/svg+xml .svg .svgz
    
    	# Video
    
    	AddType video/asf .asf .asx .wax .wmv .wmx
    
    	AddType video/avi .avi
    
    	AddType video/quicktime .mov .qt
    
    	AddType video/mp4 .mp4 .m4v
    
    	AddType video/mpeg .mpeg .mpg .mpe
    
    	# PDF
    
    	AddType application/pdf .pdf
    
    	# Flash
    
    	AddType application/x-shockwave-flash .swf
    
    	# Font
    
    	AddType application/x-font-ttf .ttf .ttc
    
    	AddType application/vnd.ms-fontobject .eot
    
    	AddType application/x-font-otf .otf
    
    	# Audio
    
    	AddType audio/mpeg .mp3 .m4a
    
    	AddType audio/ogg .ogg
    
    	AddType audio/wav .wav
    
    	AddType audio/wma .wma
    
    	# Zip/Tar
    
    	AddType application/x-tar .tar
    
    	AddType application/x-gzip .gz .gzip
    
    	AddType application/zip .zip
    
    </IfModule>
    
    <IfModule mod_expires.c>
    
    	ExpiresActive On
    
    	# Text
    
    	ExpiresByType text/css A31536000
    
    	ExpiresByType application/x-javascript A31536000
    
    	ExpiresByType text/html A3600
    
    	ExpiresByType text/richtext A3600
    
    	ExpiresByType text/plain A3600
    
    	ExpiresByType text/xml A3600
    
    	# Image
    
    	ExpiresByType image/gif A31536000
    
    	ExpiresByType image/x-icon A31536000
    
    	ExpiresByType image/jpeg A31536000
    
    	ExpiresByType image/png A31536000
    
    	ExpiresByType image/svg+xml A31536000
    
    	# Video
    
    	ExpiresByType video/asf A31536000
    
    	ExpiresByType video/avi A31536000
    
    	ExpiresByType video/quicktime A31536000
    
    	ExpiresByType video/mp4 A31536000
    
    	ExpiresByType video/mpeg A31536000
    
    	# PDF
    
    	ExpiresByType application/pdf A31536000
    
    	# Flash
    
    	ExpiresByType application/x-shockwave-flash A31536000
    
    	# Font
    
    	ExpiresByType application/x-font-ttf A31536000
    
    	ExpiresByType application/vnd.ms-fontobject A31536000
    
    	ExpiresByType application/x-font-otf A31536000
    
    	# Audio
    
    	ExpiresByType audio/mpeg A31536000
    
    	ExpiresByType audio/ogg A31536000
    
    	ExpiresByType audio/wav A31536000
    
    	ExpiresByType audio/wma A31536000
    
    	# Zip/Tar
    
    	ExpiresByType application/x-tar A31536000
    
    	ExpiresByType application/x-gzip A31536000
    
    	ExpiresByType application/zip A31536000
    
    </IfModule>
    
    <FilesMatch "\.(?i:css|js|htm|html|rtf|rtx|txt|xml|gif|ico|jpg|jpeg|jpe|png|svg|svgz|asf|asx|wax|wmv|wmx|avi|mov|qt|mp4|m4v|mpeg|mpg|mpe|pdf|swf|ttf|ttc|eot|otf|mp3|m4a|ogg|wav|wma|tar|gz|gzip|zip)$">
    
    	<IfModule mod_headers.c>
    
    		Header set Pragma "public"
    
    		Header append Cache-Control "public, must-revalidate, proxy-revalidate"
    
    		Header unset ETag
    
    	</IfModule>
    
    </FilesMatch>
    
    <FilesMatch "\.(?i:css|js|gif|ico|jpg|jpeg|jpe|png|pdf|swf|ttf|ttc|eot|otf)$">
    
        <IfModule mod_headers.c>
    
    		Header unset Set-Cookie
    
    	</IfModule>
    
    </FilesMatch>
    
    # END wtwp_cache
    
    # BEGIN wtwp_security
    
    <IfModule mod_rewrite.c>
    
    	RewriteEngine On
    
    	RewriteBase /
    
    	RewriteRule ^wp-admin/includes/ - [F,L]
    
    	RewriteRule !^wp-includes/ - [S=3]
    
    	RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
    
    	RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
    
    	RewriteRule ^wp-includes/theme-compat/ - [F,L]
    
    </IfModule>
    
    <Files "wp-config.php">
    
    	Order allow,deny
    
    	Deny from all
    
    </Files>
    
    Options -Indexes
    
    # END wtwp_security
  2. Use http://interconnectit.com/products/search-and-replace-for-wordpress-databases/

    Search for http://www.domain.com

    Replace with domain.com

    Don't do that again.

    If you MUST use www, this goes at the absolute TOP of your .htaccess

    # Redirect non-www urls to www
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
  3. pyroboy024911
    Member
    Posted 1 year ago #

    Ok so i did what you suggested it only made things worse broke links, and images. I was able to just restore my database back its prior state. When i used the tool i did a site wide search through all tables was i supposed to do that?

    ok so here is what i have:

    garagedoorsolutionstx.com redirects to

    http://www.garagedoorsolutionstx.com/wp-signup.php?new=garagedoorsolutionstx.com

    and my mapped domain dallasgargedoors.com redirects to

    http://www.garagedoorsolutionstx.com/wp-signup.php?new=dallasgaragedoors.com

    but http://www.dallasgargedoors.com works just fine as well as http://www.garagedoorsolutionstx.com

    when using the

    function ms_block_wp_signup() {
    if( strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php' ) !== false ) {
    wp_redirect( get_option('siteurl') );
    die;
    }
    }
    add_action('wp', 'ms_block_wp_signup', 99);

    all it does it loop back and forth between garagedoorsolutionstx.com and dallasgaragedoors.com

    what can i do to fix this been at this for a few days now

  4. pyroboy024911
    Member
    Posted 1 year ago #

    quick note:

    when i use

    # Redirect non-www urls to www
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^garagedoorsolutionstx\.com [NC]
    RewriteRule (.*) http://www.garagedoorsolutionstx.com/$1 [R=301,L]

    garagedoorsolutionstx.com no longer redirects to the signup page but

    using http://www.dallasgaragedoors.com does redirect back to

    http://www.garagedoorsolutionstx.com/wp-signup.php?new=www.dallasgaragedoors.com

    and i would also like to note that i have my domain mapping set up with just dallasgaragedoors.com which works with no redirect :/

  5. pyroboy024911
    Member
    Posted 1 year ago #

    Ok sorry to keep posting but i think i fixed my problems. I'm not even sure if this the right way of doing things, since my ultimate goal is to be SEO friendly.

    This is my .htaccess fix

    # Redirect non-www urls to www and ignores sub-domains
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    my only other concern is that i had to use this to ignore sub-domains because each network site going into the dashboard would revert back to subdomain.domain.com instead of being mapped to the specified domain i mapped it to... i just not sure that's right it because it doesn't seem every uniform to me.

Topic Closed

This topic has been closed to new replies.

About this Topic