【发布时间】:2020-10-07 07:14:33
【问题描述】:
我犯了一个严重的错误,我似乎无法撤消它!
一位客户突然想要一个网站(该网站被搁置)尽快上线。 很容易解决的问题,我只是删除了 cPanel 中的重定向。或者我是这么想的…… 然后我看到,该特定站点的重定向是 301 永久重定向,指向另一个域上的通用 404 站点。 注意:我们有一个经销商解决方案,并在同一个 cPanel 中托管多个站点作为子域。
我在 cPanel 中删除了重定向,但该站点仍然重定向到另一个域。我等了一个小时,然后是 2 - 但没有成功。
仅重定向主 url:customersite.dk -> developer-dd.dk/404
子页面工作正常:customersite.dk/subpage/
然后我等不及了,我在 cPanel 中创建了一个新的 302 重定向,将 customersite.dk 重定向到 customersite.dk/fakefrontpage/ 这行得通,因为它利用了子页面可以正常工作的事实,但我认为这是一种临时解决方法,直到我解决了真正的问题。
我认为/希望与此相关的一个问题是,facebook 共享调试器似乎无法获取该站点。因此,客户无法在社交网站上分享带有图片、标题和元文本的网站。
我该怎么办? 如何撤消已经存在几个月的 301 重定向的影响? 如果这确实是问题? 它也有 SEO 影响吗?
我在此处粘贴 .htaccess 文件:(我已将真实网址替换为 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]
【问题讨论】:
-
这能回答你的问题吗? Remove a 301 redirect from previous website
-
是的,这行得通。谢谢你。然后随着时间的推移,我猜旧的 301 将从服务器中消失。
标签: wordpress apache .htaccess redirect http-status-code-301