0

my htaccess code

RewriteCond %{THE_REQUEST} \s/detail\.php\?id=([_0-9a-zA-Z-]+)\s [NC]
RewriteRule ^temp/detail/%1? [R=301,L]
RewriteRule ^temp/detail/([_0-9a-zA-Z-]+)$ /detail.php?id=$1 [L]  

make my url like

temp.example.com/detail/xxxxxx

from

temp.example.com/detail.php?id=xxxxxx

now i want to append .html at the end, so that url become like:

temp.example.com/detail/xxxxxx.html

I need and htaccass rule, which will make my url like above, but shouldn't behave like html.

Thanks

ahmad ali
  • 1,155
  • 1
  • 9
  • 17
  • Why do you need the extension at all? It's not SEO friendly. – Daan Jan 29 '15 at 13:48
  • same question i asked, but boss is always right you know :P – ahmad ali Jan 29 '15 at 13:49
  • 1
    It's been asked several time on stackoverflow. [answer1](http://stackoverflow.com/questions/5745490/rewrite-rule-to-add-html-extension) [answer2](http://stackoverflow.com/questions/18682420/htaccess-add-html-extension-for-urls-with-or-without-trailing-slash). Then you just need to adjust the rules for your situation. – Kev Jan 29 '15 at 13:51

1 Answers1

0

Use this root .htaccess:

RewriteCond %{THE_REQUEST} \s/detail\.php\?id=([_0-9a-zA-Z-]+)\s [NC]
RewriteRule ^ detail/%1.html? [R=301,L]
RewriteRule ^detail/([_0-9a-zA-Z-]+?)(?:\.html)?$ detail.php?id=$1 [NC,L]  
Croises
  • 18,570
  • 4
  • 30
  • 47