【问题标题】:Eliminate soft 404 with htaccess使用 htaccess 消除软 404
【发布时间】:2018-04-21 13:18:25
【问题描述】:

我正在使用这个 MVC 项目作为我正在从事的项目的基础https://github.com/panique/huge

我已将该网站提交给 Google,但在抓取该网站时,Google 发现 URL http://example.com/huge-master/public 上存在软 404 错误

当我在 https://httpstatus.io/ 中尝试该 URL 时,它告诉我标题是 301 -> 200

由于我对 htaccess 完全没用,而且我不确定 Google 想要什么响应,你能告诉我需要改变什么来防止软 404 吗?

估计是htaccess的变化,所以位于http://example.com/huge-master/的htaccess如下:

# This file is - if you set up HUGE correctly - not needed.
# But, for fallback reasons (if you don't route your vhost to /public), it will stay here.
RewriteEngine on
RewriteRule ^(.*) public/$1 [L]

# Everything from is for browser caching and is totally optional

# Deflate Compression by FileType
<IfModule mod_deflate.c>
 AddOutputFilterByType DEFLATE text/plain
 AddOutputFilterByType DEFLATE text/html
 AddOutputFilterByType DEFLATE text/xml
 AddOutputFilterByType DEFLATE text/css
 AddOutputFilterByType DEFLATE text/javascript
 AddOutputFilterByType DEFLATE application/xml
 AddOutputFilterByType DEFLATE application/xhtml+xml
 AddOutputFilterByType DEFLATE application/rss+xml
 AddOutputFilterByType DEFLATE application/atom_xml
 AddOutputFilterByType DEFLATE application/javascript
 AddOutputFilterByType DEFLATE application/x-javascript
 AddOutputFilterByType DEFLATE application/x-shockwave-flash
</IfModule>

# Set browser caching to 1 month
<IfModule mod_expires.c>
 ExpiresActive On
 ExpiresByType text/css "access plus 1 month"
 ExpiresByType text/javascript "access plus 1 month"
 ExpiresByType text/html "access plus 1 month"
 ExpiresByType application/javascript "access plus 1 month"
 ExpiresByType image/gif "access plus 1 month"
 ExpiresByType image/jpeg "access plus 1 month"
 ExpiresByType image/png "access plus 1 month"
 ExpiresByType image/x-icon "access plus 1 month"
</IfModule>

<ifmodule mod_headers.c>
  # if you want to prevent your site from being embedded into other sites via an iframe (sometimes used for scam), then
  # simply uncomment these lines below. you need to have apache rewrite headers activated, usually via
  # "a2enmod rewrite headers" on the command line
  #Header set X-Frame-Options Deny
  #Header always append X-Frame-Options SAMEORIGIN
 <filesmatch "\\.(ico|jpe?g|png|gif|swf)$">
  Header set Cache-Control "max-age=2592000, public"
 </filesmatch>
 <filesmatch "\\.(css)$">
  Header set Cache-Control "max-age=604800, public"
 </filesmatch>
 <filesmatch "\\.(js)$">
  Header set Cache-Control "max-age=216000, private"
 </filesmatch>
</ifmodule>

还有另一个位于http://example.com/huge-master/public/ 的 htaccess 文件,其中包含以下内容:

# Necessary to prevent problems when using a controller named "index" and having a root index.php
# more here: http://httpd.apache.org/docs/2.2/content-negotiation.html
Options -MultiViews

# Activates URL rewriting (like myproject.com/controller/action/1/2/3)
RewriteEngine On

# Prevent people from looking directly into folders
Options -Indexes

# If the following conditions are true, then rewrite the URL:
# If the requested filename is not a directory,
RewriteCond %{REQUEST_FILENAME} !-d
# and if the requested filename is not a regular file that exists,
RewriteCond %{REQUEST_FILENAME} !-f
# and if the requested filename is not a symbolic link,
RewriteCond %{REQUEST_FILENAME} !-l
# then rewrite the URL in the following way:
# Take the whole request filename and provide it as the value of a
# "url" query parameter to index.php. Append any query string from
# the original URL as further query parameters (QSA), and stop
# processing this .htaccess file (L).
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

如果您需要更多信息,请询问。如果这还不够,我很抱歉;正如我所说,我在 htaccess 方面完全没用!

【问题讨论】:

    标签: .htaccess mod-rewrite http-status-code-404


    【解决方案1】:

    好的,所以看起来我可以忽略软 404,因为根据这篇文章它不会损害排名...... https://webmasters.stackexchange.com/questions/54811/why-does-google-report-a-soft-404-when-i-redirect-to-the-signup-page

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-28
      • 1970-01-01
      • 2017-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-10
      相关资源
      最近更新 更多