Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have content in

In the products folder, I have several html files all starting with "big-". For example:


How can I rewrite my URLs so that I could access these by typing:

Thanks in advance for any help on that!

share|improve this question

migrated from Oct 10 '12 at 12:12

This question came from our site for professional and enthusiast programmers.

Using mod_rewrite (should not change the URL in the browser):

<Directory /var/www>
  RewriteEngine on
  RewriteRule ^products/big/(product[0-9][0-9]*)$ /products/big-$1.html [L]

If the <Directory> block has a relative path, you need a RewriteBase directive too.

Using mod_alias (will change the URL in the browser):

RedirectMatch permanent /products/big/(product[0-9][0-9]*)$ /products/big-$1.html
share|improve this answer
Thank you. The solution using mod_alias works. Not the one using mod_rewrite. Also I wish the URL would not change in the browser address bar after the rewriting. Have tried playing with your mod_rewrite solution without success until now. – MrUpsidown Oct 10 '12 at 19:55
Did you put the rewrite directives in a <directory> block (see my updated answer)? What does your error.log say about your failed attempts? – Ansgar Wiechers Oct 10 '12 at 21:53
Thank you. Will try that. Not sure I understand the 'relative path' part. The root path seems to be /html/products. Checking right now with my provider to see how I can access that log file. Will report back later. – MrUpsidown Oct 11 '12 at 11:04
The documentation for the RewriteBase directive has an example. – Ansgar Wiechers Oct 11 '12 at 11:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.