使用htaccess消除软404

时间:2017-11-08 18:06:18

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

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

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

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

由于我对htaccess完全没用,而且我不确定谷歌想要的回应是什么,你能告诉我需要改变什么以防止软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时,我完全没用了!

1 个答案:

答案 0 :(得分:-1)

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