Reputation: 325
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?
Upvotes: 0
Views: 91
Reputation: 41249
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]
Upvotes: 1
Reputation: 2067
Try something like this:
RewriteRule ^(.*)$ /index.php?s=$1 [L]
Upvotes: 0