问题
I've made a grave error, and I cannot seem to undo it!
A customer all the sudden wanted a website (that was on hold) to go online asap. Easy problem to solve, I just remove the redirect in cPanel. Or so I thought... Then I saw, that the redirect for that particular site was a 301 permanent redirect, to a generic 404 site on another domain. Note: We have a reseller solution, and host several sites as subdomains in the same cPanel.
I deleted the redirect in cPanel, but the site still redirects to the other domain. I waited and hour, then 2 - but no success.
Only the main url is redirected: customersite.dk -> developer-dd.dk/404
Subpages work alright: customersite.dk/subpage/
Then I could not wait anymore, and I created a new 302 redirect in cPanel, redirecting the customersite.dk to customersite.dk/fakefrontpage/ This works, since it takes advantage of the fact, that subpages work allright, but I see it as a temporary workaround, 'till I've fixed the real issue.
A problem, that I think/hope is related to this is, that facebook sharing debugger can't seem to fetch the site. Thus, the customer can't share the site on social with images, title and meta-text.
What do I do? How do I undo the effect of the 301 redirect, that have been in place for several months? If that is in fact the issue? Does it have SEO ramifications too?
I'm pasting the .htaccess file here: (I've replaced the real url with customersite)
# BEGIN LSCACHE
# END LSCACHE
# BEGIN NON_LSCACHE
# END NON_LSCACHE
#This Apache config file was created by Duplicator Installer on 2020-03-11 15:31:23.
#The original can be found in archived file with the name .htaccess__[HASH]
# 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
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN ShortPixelWebp
# The directives (lines) between `BEGIN ShortPixelWebp` and `END ShortPixelWebp` 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
##### TRY FIRST the file appended with .webp (ex. test.jpg.webp) #####
# Does browser explicitly support webp?
# OR Is request from Page Speed
# OR does this browser explicitly support webp
# AND NOT MS EDGE 42/17 - doesnt work.
# AND is the request a jpg or png?
# AND does a .ext.webp image exist?
# THEN send the webp image and set the env var webp
RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
RewriteCond %{HTTP_USER_AGENT} "Google Page Speed Insights" [OR]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{HTTP_USER_AGENT} !Edge/17
RewriteCond %{REQUEST_URI} ^(.+)\.(?:jpe?g|png)$
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.webp -f
RewriteRule ^(.+)$ $1.webp [NC,T=image/webp,E=webp,L]
##### IF NOT, try the file with replaced extension (test.webp) #####
# AND is the request a jpg or png? (also grab the basepath %1 to match in the next rule)
# AND does a .ext.webp image exist?
# THEN send the webp image and set the env var webp
RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
RewriteCond %{HTTP_USER_AGENT} "Google Page Speed Insights" [OR]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{HTTP_USER_AGENT} !Edge/17
RewriteCond %{REQUEST_URI} ^(.+)\.(?:jpe?g|png)$
RewriteCond %{DOCUMENT_ROOT}/%1.webp -f
RewriteRule (.+)\.(?:jpe?g|png)$ $1.webp [NC,T=image/webp,E=webp,L]
</IfModule>
<IfModule mod_headers.c>
# If REDIRECT_webp env var exists, append Accept to the Vary header
Header append Vary Accept env=REDIRECT_webp
</IfModule>
<IfModule mod_mime.c>
AddType image/webp .webp
</IfModule>
# END ShortPixelWebp
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php70” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php70 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
RewriteCond %{HTTP_HOST} ^customersite\.dk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.customersite\.dk$
RewriteRule ^/?$ "https\:\/\/customersite\.dk\/fakefrontpage\/" [R=302,L]
回答1:
You should always test with a 302 redirect. Never test with 301 redirect on a production server. There no other way than clearing the cache. Please keep this in mind when playing with redirect rules.
Warning: If you do use 301 redirect and if many users visit your website. You must politely ask them to clear their cache in the page where the redirect lands on.
Credits to Remove a 301 redirect from previous website and to @FluffyKitten
来源:https://stackoverflow.com/questions/62429503/how-do-i-undo-the-effects-of-a-301-permanent-redirect-and-get-the-domain-to-poi