giany
giany

Reputation: 11

Mod_rewrite rule to remove index.php

I need to have

site.com/index.php?s=super-smash-bros-baww-SUzohN

redirected to

site.com/super-smash-bros-baww-SUzohN.

How can I do that?

Note that the number of words can be different e.g: /index.php?s=aaa-bbb-ccc needs to go to /aaa-bbb-ccc

Thanks

Upvotes: 0

Views: 566

Answers (1)

Ulrich Palha
Ulrich Palha

Reputation: 9519

Try adding the following to the .htaccess file in the root directory of your site.

RewriteEngine on
RewriteBase / 

#redirect to remove index.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?s=([^\ &]+) [NC]  
RewriteRule ^ %1? [L,R=301] 

#process the SEF Url with index.php
RewriteRule ^([-a-zA-Z]+)$ index.php?s=$1 [L]

Upvotes: 1

Related Questions