php - .htaccess 文件导致 404 错误

标签 php html .htaccess http-status-code-404 google-search-console

我有一个网站。在这个网站中,尽管所有文件都存在,但根据我的谷歌网站管理员的说法,我有一些 404 文件未找到错误。它们如下:

http://firstcovers.net/http//firstcovers.net/
http://firstcovers.net/category/1/http//firstcovers.net/
http://firstcovers.net/category/8/4/http//firstcovers.net/
http://firstcovers.net/category/17/2/http//firstcovers.net/
http://firstcovers.net/category/20/2/http//firstcovers.net/
http://firstcovers.net/facebook-cover/1317/privacy.php
http://firstcovers.net/facebook-cover/1317/terms.php
http://firstcovers.net/facebook-cover/1286/privacy.php
http://firstcovers.net/facebook-cover/338/terms.php

.htaccess文件的结构如下:

DirectoryIndex index.html.var index.htm index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml default.htm default.html home.htm index.php5 Default.html Default.htm home.html
# Use PHP5 Single php.ini as default
#AddHandler fcgid-script .php
RewriteEngine On


RewriteRule ^latest.html /index.php?latest=y [L]
RewriteRule ^random.html /index.php?random=y [L]
RewriteRule ^showall.html /index.php?showall=y [L]
RewriteRule ^about.html /about.php [L]
RewriteRule ^userupload.html /userupload.php [L]
RewriteRule ^get-timeline.html /how.php [L]

RewriteRule ^facebook-cover-([0-9]+).html /detailpage.php?cp=$1 [L]
RewriteRule ^facebook-cover/([0-9]+)/([^/]*).html /detailpage.php?cp=$1 [L]
RewriteRule ^preview/([0-9]+)/([^/]*).html /detailpage.php?preview=y&cp=$1 [L]
RewriteRule ^category/([^/]*)/([^/]*).html /index.php?cat=$1 [L]
RewriteRule ^category/([^/]*)/([^/]*)/([^/]*).html /index.php?cat=$1&page=$2 [L]
RewriteRule ^cover-([0-9]+).html  /image.php?picID=$1 [L]
RewriteBase /
RewriteRule ^css/(.*\.css) /combine.php?type=css&files=$1
RewriteRule ^javascript/(.*\.js) /combine.php?type=javascript&files=$1

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
<FilesMatch "\\.(js|css|html|htm|php|xml)$">
# compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
SetOutputFilter DEFLATE
</FilesMatch>

Header set Expires "Thu, 15 Apr 2030 20:00:00 GMT"
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER}     !^$
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} .(gif|jpe?g?|png)$ [NC]
RewriteCond %{HTTP_REFERER}     !^https?://([^.]+.)?firstcovers. [NC]
RewriteRule .(gif|jpe?g?|png)$ - [F,NC,L]
</ifModule>
RewriteCond %{HTTP_REFERER} !^http://www.google.com/reader/view/.*$ [NC]
# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On 
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>

FileETag MTime Size

我已尽力更改.htaccess文件的正则表达式。但我仍然犯了一些错误。我无法追踪那个错误。

我请求本网站的成员帮助我。

**提前致谢。

你的 friend 。

V K 锯。**

最佳答案

对于以下 404

http://firstcovers.net/facebook-cover/1317/privacy.php
http://firstcovers.net/facebook-cover/1317/terms.php
http://firstcovers.net/facebook-cover/1286/privacy.php
http://firstcovers.net/facebook-cover/338/terms.php

修改您的 facebook-cover匹配 .php 的规则网址也是如此。

RewriteRule ^facebook-cover/([0-9]+)/([^/]*)\.(php|html)$ /detailpage.php?cp=$1 [L]

其余404链接

http://firstcovers.net/http//firstcovers.net/
http://firstcovers.net/category/1/http//firstcovers.net/
http://firstcovers.net/category/8/4/http//firstcovers.net/
http://firstcovers.net/category/17/2/http//firstcovers.net/
http://firstcovers.net/category/20/2/http//firstcovers.net/

不是由您的 .htaccess 文件生成的。检查您的 php 代码是否生成了错误的 URL。某处附加 http//firstcovers.net/在最后。您正在使用一些自定义标签(例如 <g:plusone> ),这也可能是此类标签库中的一个错误。

关于php - .htaccess 文件导致 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29180580/

相关文章:

php - PHP脚本中的Mysql错误

javascript - 是否可以通过 ajax 提交表单的一部分和表单 'normally' 的另一部分?

c# - 更改 MVC 主页登陆页面 : No service for type 'Microsoft.Extensions.DependencyInjection.IServiceCollection' has been registered

apache - Apache 有没有办法默默地忽略无法识别的 .htaccess 指令?

php - 通过模型上的特定方法订购 CGridView

linux - session.serialize_handler 作为 igbinary 导致 "igbinary_unserialize_header: unsupported version"

jquery - 如何将占位符添加到下拉搜索输入中

html - 为什么 flex 元素不缩小过去的内容大小?

.htaccess - 想要将域重定向到子文件夹中的博客,直到完整站点启动

.htaccess - 使用 React 在 apache 上刷新页面不起作用