douxiajia6309 2019-04-18 18:23
浏览 73
已采纳

重定向到404页面,BAD / FAKE页面无法正常工作

*Note - Site does direct to https for SSL cert

Ok this is on a live site so I'll be able to give links to test.

So if you access my site https://thebigmmorpglist.com and put in a random fake page such as https://thebigmmorpglist.com/nosuchpage.php it will keep the url as https://thebigmmorpglist.com/nosuchpage.php but have the looks of the home page with a messed up stylesheet. Also say you go to https://thebigmmorpglist.com/12-sky-2/nosuchpage.php it will also show the home page while keeping the url as https://thebigmmorpglist.com/12-sky-2/nosuchpage.php but have NO STYLESHEET AT ALL (Probably because its in a different directory. I am so confused on how to fix this, I believe I have the redirects correct in my .htaccess file.

(Sorry if I am wording / describing anything wrong)

Ive already tried changing the location of my error page and changing around the order / layout of my redirect code. I am at a complete loss as to hwo I can correct this and I cannot find anything on Stack Overflow that replicates my issue.

ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . /index.php [L]
</IfModule>

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>

RewriteEngine On
RewriteCond %{HTTP_HOST} thebigmmorpglist\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://thebigmmorpglist.com/$1 [R,L]

I am hoping for the fake page to redirect to error.php that is located in my root directory...

  • 写回答

1条回答 默认 最新

  • doucu7330 2019-04-18 18:57
    关注

    I was dumb and duped the redirect for https due to my site no longer being a wordpress site...

    Had to Remove this code

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
    RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule . /index.php [L]
    </IfModule>
    

    Fixed / Working Code:

    ErrorDocument 403 /error.php
    ErrorDocument 404 /error.php
    ErrorDocument 500 /error.php
    
    <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
    Header set Cache-Control "max-age=290304000, public"
    </FilesMatch>
    
    RewriteEngine On
    RewriteCond %{HTTP_HOST} thebigmmorpglist\.com [NC]
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
    RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^(.*)$ https://thebigmmorpglist.com/$1 [R,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大