0

Currently visitors see my website in this way: example.com/index.php?s=anyword+to+search

I would like to change to example.com/anyword+to+search

My current .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>

Does anyone know how?

2

2 Answers 2

1

Try this rule to redirect query string to short url :

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]
Sign up to request clarification or add additional context in comments.

Comments

0

Try something like this:

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

3 Comments

Sorry, but where should I add it? I tried it adding right after the SSL redirection, but didn't work.
Try removing the mod_php5 blocks and placing that line instead.
I think your artist rules are interfering as well. Try removing them also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.