2016-11-09 52 views
0

好吧,我在Windows 10計算機上重新安裝了WAMP,最新版本 - 它工作正常,只是我試圖讓mod_xsendfile與我的一個項目一起工作,並且我想升級以查看它是否正確有什麼區別。

但是,我在重新安裝後遇到了一個奇怪的問題。出於某種原因,它似乎並沒有真正使用.htaccess(它的確如此,但似乎有些奇怪 - 如果我註釋掉.htaccess內容,它會停止處理CSS等,所以它可以工作)。

下面是具體問題 - 我使用.htaccess製作「漂亮的網址」 - 所以我可以寫domain.com/gallery而不是(後者的作品)。如果我寫第一個,則頁面上不顯示任何內容,因爲如果我回顯$_GET['page']變量,則返回gallery.php - 而不僅僅是gallery。如果我在做index.php?page=gallery後回顯出同樣的結果,它應該會迴應gallery。我只是不知道它在哪裏得到.php位。它不會在代碼中分配,它只是在這裏發生的(該網站是使用MAMP在Mac上開發的,代碼在那裏工作沒有問題,或多或少有相同的版本:Apache 2.4.x和PHP 7.x)。

所以,這裏是我的.htaccess(雖然我想也許是別的什麼):

#Gzip 
<ifmodule mod_deflate.c> 
SetOutputFilter DEFLATE 
</ifmodule> 
#End Gzip 

RewriteEngine on 

RewriteRule (script|style|users|webgfx|translations|setup|conf)/(.+)$ $1/$2 [L,QSA,NC] 

RewriteRule ^(update_cookie.php|showfile.php|current_uploads.php|deletefile.php|language.php|gallery.php|quotes.php|retrieve_folder.php|check_email.php|config.php|delete_setup.php|functions.php|get_settings.php|get_update_info.php|get_userinfo.php|license.txt|login.php|process_search.php|process_setup.php|returnmessages.php|send_email.php|statistics_processing.php|update_settings.php|upload.php|process_upload.php|create_public_link.php)$ $1 [L,QSA] 

RewriteRule ^(coreclass.php|coreclass|functions.php|functions|language.php|language)$ index 

RewriteRule ^index.php?page=index|^index index.php [L,QSA,NC] 

RewriteRule ^(.*)$ index.php?page=$1 [L,QSA,NC] 

<IfModule mod_expires.c> 
# Enable expirations 
ExpiresActive On 
# Default directive 
ExpiresDefault "access plus 1 month" 
# My favicon 
ExpiresByType image/x-icon "access plus 5 years" 
# Images 
ExpiresByType image/gif "access plus 1 month" 
ExpiresByType image/png "access plus 1 month" 
ExpiresByType image/jpg "access plus 1 month" 
ExpiresByType image/jpeg "access plus 1 month" 
# CSS 
ExpiresByType text/css "access 1 month" 
# Javascript 
ExpiresByType application/javascript "access plus 1 year" 
</IfModule> 

是否有Apache或東西的任何地方的設置,將自動添加這樣的「好網址.php.html 「? 注意:我在文件夾中有一個gallery.php文件,但它只能通過index.php?page=gallery

加載如果還有其他東西需要提供,請告訴我。

回答

-1

你必須排除你重寫到目標:

RewriteEngine on 

RewriteRule ^((?!index\.php|.*\.).*)$ /index.php?page=$1 [L,NC,QSA] 
+0

不,你其實不需要那樣做 – junkfoodjunkie