2015-06-09 134 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] 
相关问题