Say I have content in www.domain.com/products/

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!


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
| 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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