Iv到处看,几乎尝试了一切。我不完全理解.htaccess重写。
所以也许有人可以在我的.htaccess中快速指出一些错误的东西?
这是Perch CMS。每个页面都有效,但是当它找不到页面时,我得到500错误,而不是404,我认为这与循环或某事有关。该错误在主页上有效。
http://kieranhunter.co.uk/nopage - 作品(404)
http://kieranhunter.co.uk/about/nopage - 不起作用(500)
我的.htaccess
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^detail/([a-zA-Z0-9-]+)$ /detail.php?s=$1 [L]
RewriteRule ^category/([a-zA-Z0-9-/]+)$ /category.php?cat=$1 [L]
RewriteRule ^blog/([a-zA-Z0-9-]+)$ /blog/post.php?s=$1 [L]
RewriteRule ^blog/([a-zA-Z0-9-]+)/preview$ /blog/post.php?s=$1&preview=all [L]
RewriteRule ^blog/category/([a-zA-Z0-9-]+)/page/([0-9]+)/{0,1}$ /blog/archive.php?cat=$1&page=$2 [L]
RewriteRule ^blog/category/([a-zA-Z0-9-]+)$ /blog/archive.php?cat=$1 [L]
RewriteRule ^blog/date/([a-zA-Z0-9-]+)/page/([0-9]+)/{0,1}$ /blog/archive.php?year=$1&page=$2 [L]
RewriteRule ^blog/date/([a-zA-Z0-9-]+)$ /blog/archive.php?year=$1 [L]
RewriteRule ^blog/date/([a-zA-Z0-9-]+)/([a-zA-Z0-9-/]+)/page/([0-9]+)/{0,1}$ /blog/archive.php?year=$1&month=$2&page=$3 [L]
RewriteRule ^blog/date/([a-zA-Z0-9-]+)/([a-zA-Z0-9-/]+)$ /blog/archive.php?year=$1&month=$2 [L]
RewriteRule ^blog/tag/([a-zA-Z0-9-]+)/page/([0-9]+)/{0,1}$ /blog/archive.php?tag=$1&page=$2 [L]
RewriteRule ^blog/tag/([a-zA-Z0-9-]+)$ /blog/archive.php?tag=$1 [L]
RewriteRule ^blog/([a-zA-Z0-9-]+)/([a-zA-Z0-9-/]+)/page/([0-9]+)/{0,1}$ /blog/archive.php?year=$1&month=$2&page=$3 [L]
RewriteRule ^blog/([a-zA-Z0-9-]+)/([a-zA-Z0-9-/]+)$ /blog/archive.php?year=$1&month=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
ErrorDocument 400 /404.php
ErrorDocument 401 /404.php
ErrorDocument 403 /404.php
ErrorDocument 404 /404.php
ErrorDocument 500 /404.php
ErrorDocument 502 /404.php
ErrorDocument 504 /404.php
RewriteRule (.*).xml(.*) $1.php$2 [nocase]
#Old posts re-direct
Redirect 301 /my-portfolio /portfolio
Redirect 301 /welcome-to-my-portfolio-site /blog/welcome-to-my-portfolio-site
Redirect 301 /new-canon-450d /blog/my-new-canon-450d
Redirect 301 /google-authorship-now-works /blog/how-to-make-your-google-authorship-work
Redirect 301 /my-first-codepen /blog/my-first-codepen
Redirect 301 /wordpress-theme-development /blog/developing-my-custom-wordpress-theme
Redirect 301 /my-review-on-sniper-elite-3-xbox-one /blog/my-review-on-sniper-elite-3-xbox-one
Redirect 301 /custom-project-types-for-your-portfolio /blog/custom-project-types-for-your-portfolio
Redirect 301 /custom-social-share-buttons-author-information /blog/custom-social-share-buttons-with-author-information
Redirect 301 /social-media-icons-with-hover-titles /blog/social-media-icons-with-hover-titles
Redirect 301 /creating-perfect-favicon /blog/creating-the-perfect-favicon
Redirect 301 /javascript-image-animation-frames /blog/javascript-image-animation-frames
Redirect 301 /hide-your-arms-t-shirt-blog /blog/hide-your-arms-t-shirt-blog
Redirect 301 /the-joy-of-sublime-text-2 /blog/the-joy-of-sublime-text-2
Redirect 301 /implementing-wordpress-post-formats /blog/implementing-wordpress-post-formats
Redirect 301 /using-icomoon-icons /blog/the-best-way-to-implement-font-icons
Redirect 301 /how-to-test-your-fish-water-and-resolving-nitrite-poisoning /blog/how-to-test-your-fish-water-and-resolving-nitrite-poisoning
Redirect 301 /update-on-my-aquariums-nitrite-poisoning /blog/update-on-my-aquariums-nitrite-poisoning
Redirect 301 /next-previous-wordpress-post-links /blog/next-previous-wordpress-post-links
Redirect 301 /shouldnt-using-target_blank-outbound-links /blog/why-you-shouldnt-be-using-target-blank-for-outbound-links
Redirect 301 /set-photoshop-document-brush-presets-illustrate-using-tablet /blog/how-to-set-up-your-photoshop-document-and-brush-presets-to-illustrate-using-a-tablet
Redirect 301 /migrating-wordpress-perch-cms /blog/migrating-from-wordpress-to-perch-cms
Redirect 301 /uk-plugs-logo-web-design /blog/uk-plugs-logo-web-design
Redirect 301 /pug-love-photoshop-illustration /blog/pug-love-photoshop-illustration
Redirect 301 /feather-threadless-submission /blog/feather-threadless-submission
Redirect 301 /fresh-new-theme-from-themeforest /blog/fresh-new-theme-from-themeforest
Redirect 301 /5-web-design-and-blog-trends-for-you-to-think-about-for-2014 /blog/5-web-design-and-blog-trends-for-you-to-think-about-for-2014
Redirect 301 /social-media-image-sprites /blog/social-media-image-sprites
Redirect 301 /final-fantasy-x-x-2-hd /blog/final-fantasy-xx-2-hd-review
#block libwww-perl
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
#re-direct http://www. to http://
RewriteCond %{HTTP_HOST} ^www\.kieranhunter\.co.uk$
RewriteRule ^/?$ "http\:\/\/kieranhunter\.co.uk\/" [R=301,L]
</IfModule>
谢谢
基兰
更新:这篇帖子修好了我觉得!! htaccess returning 500 error when needs to be 404