2017-06-22 215 views
1

您好我現在有這個作爲我的.htaccess文件:查詢字符串路徑

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteRule ^/(assets|modules|plugins)/ - [NC,L,QSA]                                         
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -s                                         
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d [OR]                                        
RewriteRule (.*) - [NC,L,QSA,S=3]                                             
RewriteRule ^/(.*)/(.*)$ /$1?type=$2 [NC,QSA]                                          
RewriteRule ^/(.*)$ /index.php?page=$1 [NC,L,QSA] 
</IfModule> 

這是從Apache虛擬主機配置移動爲.htaccess,但我得到404的。

例如:我想這個頁面http://stripsync.com/index.php?page=venue看起來像這樣http://stripsync.com/venue

我在做什麼錯?所有幫助非常感謝!

回答

0

將其更改爲此,因爲您將其移至.htaccess(其不包括它們在匹配中),因此已在此上下文中刪除,因此將其更改爲除去開放正斜槓。

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteRule ^(assets|modules|plugins)/ - [NC,L]                                         
    RewriteCond %{ENV:REDIRECT_REWRITTEN} =1 [OR] 
    RewriteCond %{REQUEST_FILENAME} -s [OR] 
    RewriteCond %{REQUEST_FILENAME} -d 
    RewriteRule^- [L] 
    RewriteRule ^(.*)/(.*)$ /$1?type=$2 [QSA,L,E=REWRITTEN:1] 
    RewriteRule ^(.*)$ /index.php?page=$1 [QSA,L,E=REWRITTEN:1] 
</IfModule> 

我刪除了未使用的標誌並捕獲。

+0

當我使用你的例子時,我得到一個500錯誤。 它有助於提供我的全局變量和index.php文件的例子嗎? – ewoah

+0

對不起。我更新了規則,你可以再試一次嗎?如果它仍然是500,請讓我知道錯誤日誌說什麼。 – SuperDuperApps

+0

它的工作表示感謝! – ewoah