1

How i do rewrite urls the following by .htacess:

"http://www.domain.com/blog/" To "http://www.domain.com/blog.html"

and

"http://www.domain.com/general.php?code2" To "http://www.domain.com/this-is-ilas.html"

Thanks.

Adnan Khan
  • 897
  • 5
  • 14
  • 23
  • possible duplicate of [How can I display SEO friendly URLs using mod\_rewrite?](http://stackoverflow.com/questions/1513311/how-can-i-display-seo-friendly-urls-using-mod-rewrite) – JochenJung Apr 07 '14 at 12:07

2 Answers2

2

This is a simple rule with mod_rewrite:

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^blog\.html$ /blog/ [L,NC]

RewriteRule ^this-is-ilas\.html$ /general.php?code2 [L,NC,QSA]
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

Take a look at mod_rewrite. It will allow you to change how your URLs appear to the user, while still calling the correct script on the backend. This includes masking any PHP urls to display as .html. A possible solution (though it may need some work; place it in your .htaccess file):

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^ilas\.html$ general.php?=2

See also: How to rewrite .php to .html with mod_rewrite rules

Community
  • 1
  • 1
Julio
  • 2,261
  • 4
  • 30
  • 56