404重定向到页面无法正常工作php / htaccess

时间:2018-09-19 04:16:55

标签: php .htaccess http-status-code-404

我的php htaccess 404重定向有一个小问题-它没有重定向。

我有htaccess设置,用于删除文件名/页面的扩展名,我想知道这是否是导致问题的原因。但是,我被困住了,似乎无法弄清楚。

不是,它只是一直将所有错误重定向到索引页面。

我尝试了这个建议,但没有运气-Rewrite URL after redirecting 404 error htaccess

有什么建议吗?

这是我的htaccess:

Options -Indexes +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www.sitename.com$ [NC]
RewriteRule ^(.*)$ http://sitename.com/$1 [R=301,L]

## hide .php extension snippet

# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]

# To internally forward /dir/foo to /dir/foo.php
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME}.php -f
#RewriteRule ^(.*?)/?$ $1.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index(\?|\ )
RewriteRule ^ /%1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule . index [L] 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.(html?|php[45]?)(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]*/)*)index\.(html?|php[45]?)$ http://sitename.com/$1 [R=301,L]


#if query string is empty
RewriteCond %{QUERY_STRING} ^$
#match on / for root, or .index.php in request and send to query string version 
RewriteRule ^invoices.php?$ /invoices?status=open [R=301,L] 
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^projects.php?$ /projects?status=open [R=301,L] 

#RewriteRule ^(/|invoices.php)?$ /invoices?status=open [R=301,L]
#RewriteRule ^(/|projects.php)?$ /projects?status=open [R=301,L]


ErrorDocument 400 /errors.php
ErrorDocument 403 /errors.php
ErrorDocument 404 /errors.php
ErrorDocument 405 /errors.php
ErrorDocument 408 /errors.php
ErrorDocument 500 /errors.php
ErrorDocument 502 /errors.php
ErrorDocument 504 /errors.php

0 个答案:

没有答案