我一直在這個網站上工作了很長時間。我使用.htaccess文件來獲得乾淨的URL。這種精細的工作我個人的測試服務器,這是HTTP,並在我的本地,但移動到生產服務器(與啓用HTTPS和工作)以後,一些規則沒有工作除非第一個字母大寫,否則Mod_rewrite不適用於某些規則? HTTPS服務器
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^index/?$ index.php [NC,L]
RewriteRule ^home/?$ index.php [NC,L]
RewriteRule ^main/?$ index.php [NC,L]
RewriteRule ^about/?$ about.php [NC,L]
RewriteRule ^music/?$ music.php [NC,L]
RewriteRule ^shows/?$ shows.php [NC,L]
RewriteRule ^blog/?$ blog.php?page=1 [NC,L]
RewriteRule ^blog/([\0-9]+)/?$ blog.php?page=$1 [NC,L]
RewriteRule ^contact/?$ contact.php [NC,L]
RewriteRule ^profile/?$ profile.php [NC,L]
RewriteRule ^manage-site/?$ manage-site.php [NC,L]
RewriteRule ^my-blog-posts/?$ my-blog-posts.php [NC,L]
RewriteRule ^new-blog-post/?$ new-blog-post.php [NC,L]
RewriteRule ^edit-music/?$ edit-music.php [NC,L]
RewriteRule ^admin-login/?$ admin-login.php [NC,L]
RewriteRule ^admin/?$ admin-login.php [NC,L]
RewriteRule ^forgot-password/?$ forgot-password.php [NC,L]
RewriteRule ^password-reset/?$ password-reset.php [NC,L]
RewriteRule ^blog/article/([\w-]+)/?$ blog-post.php?slug=$1 [NC,L] #handle requests for Individual Blog Posts
RewriteRule ^blog/article/([\w-]+)/([^/\.]+)/?$ blog-post.php?slug=$1&reply-comment=$2 [NC,L] #handle requests for Individual Blog Posts with a comment specified for replies when JavaScript is disabled
RewriteRule ^password-reset/([^/]+)/?$ password-reset.php?token=$1 [NC,L] #handle requests for password-reset.php with the token included in a nicer-looking url
</IfModule>
ErrorDocument 404 /404.php
基本上任何有一個連字符的規則,即管理網站,給了我一個404錯誤,除非我使用它,即管理網站 - 這很好。
任何想法?
在該片段中沒有看到解釋連字符依賴性或區分大小寫的任何內容。可能404在RewriteRule執行之前(或之後)發生。錯誤日誌通常會爲404提供附加信息。重寫日誌記錄還可能提供更多線索: RewriteLog日誌/ rewrite.log RewriteLogLevel 9 –
看起來它實際上是多個頁面,而不僅僅是連字符。原本,我只注意到帶連字符的人。幸運的是,網站上的每一個鏈接/重定向實際上都是大寫的,因爲我覺得它很美觀。儘管如此,仍然很奇怪。 我試圖刪除ErrorDocument行,但這並沒有幫助,除了改回默認的Apache 404頁面。 無效的命令「RewriteLog」,也許是拼寫錯誤或定義的不包括在服務器配置的模塊 ^沒有運氣的rewritelog – Chris
我也注意到,但是:週五23年1月22日:55:32.996435 2016年] [協商:錯誤] [pid 22241] [client 47.55.91.133:52285] AH00687:協商:發現匹配請求的文件:/ var/www/html/admin-login(無可協商)。 所以如果這是Apache 2.4,重寫日誌記錄與此處記錄的有所不同,那麼重寫規則只是簡單地不會引起admin-login,它應該是重寫它到admin-login.php – Chris