0

How to change this url

http://domain.com/search/song

to

http://domain.com/search/song.html

.htaccess File

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) index.php?/$1 [QSA,L] 

Black Sheep
  • 6,604
  • 7
  • 30
  • 51
Cracker
  • 11
  • 1

1 Answers1

2

Try to add string

RewriteRule ^(/search/song)$ $1.html [L,R=301]

right after RewriteEngine On

If this doesn't work, try to put this:

RedirectMatch 301 ^(/search/song)$ $1.html

This should work perfectly.

bfday
  • 163
  • 2
  • 11
  • I edited your question to remove the leading slash from the Rule's pattern, leading slash is not allowed in htaccess context. – Amit Verma Apr 17 '16 at 15:37