2015-06-09 133 views
0

目前遊客看到我這樣的網站:example.com/index.php?s=anyword+to+search的.htaccess - 刪除查詢字符串

我想改變example.com/anyword+to +搜索

我目前的.htaccess:

Options -Indexes +FollowSymLinks  
RewriteEngine On 
RewriteBase/

RewriteCond %{HTTPS} off 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{THE_REQUEST} !/artist/ [NC] 
RewriteRule ^(.*)$ artist/$1 [L,R] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 

<IfModule mod_php5.c> 
    RewriteRule ^(.*)$ index.php/$1 [L]  
</IfModule>  

# the following is for rewritting under FastCGI 
<IfModule !mod_php5.c>  
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

有誰知道怎麼樣?

+2

不同於論壇的網站,我們不使用「謝謝」,或者「任何幫助讚賞「,或簽名[so]。請參閱「[應該'嗨','謝謝',標語和致敬從帖子中刪除?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be - 刪除 - 從帖子)。順便說一句,它是「預先感謝」,而不是「感謝先進」。 –

+0

爲什麼你將所有內容都路由到'/ artist /'文件夾? – anubhava

回答

0

嘗試這樣:

RewriteRule ^(.*)$ /index.php?s=$1 [L] 
+0

對不起,我應該在哪裏添加它?它在SSL重定向後添加,但沒有工作 –

+0

嘗試刪除'mod_php5'塊並放置該行代替 –

+0

對不起,它沒有工作,它返回404. –

1

試試這個規則查詢字符串重定向到短網址:

Options -Indexes +FollowSymLinks  
RewriteEngine On 
RewriteBase/
#http to https 
RewriteCond %{HTTPS} off 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

#Query string to short url 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/index\.php\?s=([^&\s]+) [NC] 
RewriteRule^%1? [R,L] 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*?)/?$ index.php?s=$1 [QSA,B,NC,L] 
相關問題