douju6752 2019-07-14 12:17
浏览 93

如何修复.htaccess中的问题RewriteRule与重定向ErrorDocument的相对路径

I'm asking for help with a redirection problem with my .Htaccess file When redirecting 401, 403, 404... in a subfolder of my site, the display of the error is in the path of the subfolder and not at the root of the site.

If www.mysite.com/test/index.html not exist, the error show www.mysite.com/test/index.html with my 404 page include without my CSS

I have a redirection rule to shorten urls in the htaccess. The URL shortener use a random combination of 4 alpha digit characters

www.mysite.com/cder
www.mysite.com/adj4

I searched at the base to create a dynamic error page to log visitors and robots spammer in a text file

Thank you for your answers and advice on the right method

# URL rewriting for Shorten Urls
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /tinyurl.php?id=$1 [QSA,NC,L]

# ErrorDocument
ErrorDocument 400  /?page=error&code=400
ErrorDocument 401  /?page=error&code=401
ErrorDocument 403  /?page=error&code=403
ErrorDocument 404  /?page=error&code=404
ErrorDocument 405  /?page=error&code=405
ErrorDocument 408  /?page=error&code=408
ErrorDocument 410  /?page=error&code=410
ErrorDocument 411  /?page=error&code=411
ErrorDocument 412  /?page=error&code=412
ErrorDocument 413  /?page=error&code=413
ErrorDocument 414  /?page=error&code=414
ErrorDocument 415  /?page=error&code=415
ErrorDocument 500  /?page=error&code=500
ErrorDocument 501  /?page=error&code=501
ErrorDocument 502  /?page=error&code=502
ErrorDocument 503  /?page=error&code=503
ErrorDocument 506  /?page=error&code=506
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题
    • ¥15 Visual Studio问题
    • ¥20 求一个html代码,有偿