0

I've tried dozens of rules in my htaccess, but none have helped me.

I have a website where I want to redirect users to a new page, based on a word in the URL.

So

https://www.example.com/product/product-1 

should redirect to

https://www.example.com/product-1 

Always, without exceptions. Any ideas?

New contributor
Kevinster is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

closed as unclear what you're asking by Stephen Ostermiller Jan 11 at 12:19

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    You need to show what you have tried. This is a seemingly trivial redirect, so maybe there is something fundamental at fault here? Your example shows a single source URL and a single destination URL... is there a more complex mapping here? Is everything after /product/ (eg. product-1 in your example) variable? Do you have other directives in your .htaccess file? – MrWhite Jan 11 at 11:23
0
            RewriteEngine on
            RewriteRule ^/product/(.*)$ https://example.com/$1 [R=301,L]
  • 2
    In .htaccess you need to remove the slash prefix from the RewriteRule pattern. However, since the OP has already "tried dozens of rules", it's quite probable they are putting the directive in the wrong place and/or have conflicts with existing directives. – MrWhite Jan 11 at 11:42

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