Can someone help me with .htaccess
file?
I changed my domain name from lets say olddomain.com
to newdomain.com
without building a completely different site.
I just went in and changed the URL and fixed a few things in cPanel or something and then parked the domain and went on with my life. It was a new site so I didn't think it was important to redirect as I wasnt getting any traffic anyway.
Now my super important blog post is ranking and but on my old URL and there is absolutely no way to 301 redirect anything!
I tried plugins its basically only giving me the option to 301 redirect from my new URL.
I didn't do my homework I know.
This is what I did:
- Changed urls directly on the same wordpress site
- submitted a new sitemap on google search console
- a few blog posts didn't get index because they obviously see it as duplicate content
- parked the old domain
2 months later:
- still ranking on my old blog post
- still not indexed on my new one
- removed the parked domain to see if it makes a difference
- removed the site map on the old domain
- asked google to request indexing
It's not indexed, now the blog post is not coming to my site obviously since I removed the parked domain.
I contacted the siteground customer service they told me I had to edit my .htaccess
file. Through their tutorial it isn't showing the exact same lines of code.
this is siteground's tutorial : To ensure your new primary domain name is used, first park the previous primary one as shown in this tutorial and then redirect the old domain name to your new one by inserting this code to the .htaccess file in your public_html folder (you can modify/create that file via File Manager in Site Tools):
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
this is MY .htaccess
code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
# END HTTPS
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Any advice would be greatly appreciated. I definitely learned a lesson here.
I will obviously repark the domain if I can fix this .htaccess
file.