1

I found a lot of similar answers but so far I could not manage the right thing that I want. It seems very easy or maybe somebody already answered but for me it's not working anymore..

So at the end I want https://example.com/product/624567

In my htaccess file I have already a rule something like this

RewriteEngine On RewriteRule ^([a-z0-9-]{1,40})/([0-9]{1,12})$ fixMe.php?request=$2 [L] 

Now if someone calls a URL following the above mentioned pattern with or without https all time it should redirect to the desired url(https://example.com/product/624567). To achieve this redirect I set another rule something like

RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} product RewriteRule ^product/([0-9]{1,12})$ https://%{HTTP_HOST}/product/$1 [L,R=301,NE] 

But I am always getting a 404 error!! Could anyone please help me what i am doing wrong. Thanks

1 Answer 1

2

Try with:

RewriteCond %{HTTPS} off RewriteRule ^product/[0-9]{1,12}$ https://%{HTTP_HOST}%{REQUEST_URI} [NC,NE,L,R=301] 

But just place the lines after RewriteEngine On and before RewriteRule ^([a-z0-....;

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.