Home / Web Hosting / Change a URL with mod_rewrite

Change a URL with mod_rewrite

Apache Software Foundation LogoQuestion: My current website URL looks like http://mydomain.com/index.php?page=creative. How can I remove the index.php and question mark to make it look more like a regular page address?

Answer: If your web server is Apache, you should be able to do this with mod_rewrite. If you have a shared hosting account, first make sure that your web host has enabled mod_rewrite. Then, create an .htaccess file or edit your current one, placing the following strings inside it:

RewriteEngine on
RewriteRule ^([^/\.]+).html$ index.php?page=$1 [L]

The above will change http://mydomain.com/index.php?page=creative to:

http://mydomain.com/creative.html

This will make it easier for users to remember your URLs and possibly for search engines to index them.

Check Also

servers

Importance of web hosting to business

The world of business is very ruthless and unfair in some cases. It is a …