Alex Angelico
Alex Angelico

Reputation: 4065

apache htaccess redirect many url to one

Sorry guys if this is a lame question, but the examples i found dont quite work the way I want

What I'm tryint to achive is send any web site request for products to "producto.php" but keeping the descriptive URL for the search engines.

This is the .htaccess I have

RewriteRule ^en/products(/)?$ /en/products/tactical/ [R]
RewriteRule ^es/productos(/)?$ /es/productos/tactico/ [R]

RewriteRule ^en/products/tactical(/)?$ /app/view/productos.php
RewriteRule ^en/products/rescue(/)?$ /app/view/productos.php
RewriteRule ^en/products/diving(/)?$ /app/view/productos.php

RewriteRule ^es/productos/tactico(/)?$ /app/view/productos.php
RewriteRule ^es/productos/rescate(/)?$ /app/view/productos.php
RewriteRule ^es/productos/buceo(/)?$ /app/view/productos.php

This works, but is difficult to maintain. I cannot find how to convert the three ^en/products/tactical(/)?$, ^en/products/rescue(/)?$, ^en/products/diving(/)?$ to just one rule. I could not make it work with the typical /[A-Za-z], probaply because I'm not sure how to use it

Upvotes: 0

Views: 173

Answers (1)

Tomasz Kowalczyk
Tomasz Kowalczyk

Reputation: 10467

RewriteRule ^en\/products\/([a-zA-Z]+)\/?$ /app/view/productos.php?product=$1

What would pass string between slashes as a parameter.

Upvotes: 1

Related Questions