htaccess dynamic url redirect to static url - .htaccess

I have searched for my specific htaccess redirect from dynamic url to static url but can't found proper one. So here is the question.
I want to redirect
www.example.com/directory/?year=2014&month=September
www.example.com/directory/?year=2014&month=October
www.example.com/directory/?year=2015&month=December
and so on
To
www.example.com/directory/2014/September
www.example.com/directory/2014/October
www.example.com/directory/2015/December
and so on
Hope you will definitely help with step by step process and how it work.
Thanks in advance

You can do that in the /directory/.htaccess file:
RewriteEngine on
RewriteRule ^(\d+)/(\w+)/?$ ?year=$1&month=$2 [L]

Related

Redirect from old page to new page using .htaccess

I am trying to redirect from contactus.php to contactus.html using .htaccess file with below rule. But not working for me and tried with google solutions, still not working.
Solution 1
RewriteEngine On
RewriteRule 301 www.domain.com/contactus.php www.domain.com/contactus.html
Solution 2
RewriteEngine On
RewriteRule ^contactus.php$ www.domain.com/contactus.html[L,R=301]
Both are not working for me.
Can you please help me out on this?
if your new page is contact.html then in htaccess file you are using www.domain.com/contactus.html which should be www.domain.com/contact.html

redirect any link to specific url (.htaccess)

I want to redirect
/public/courses/((anything)) to /courses
this is my code , it does not working
Redirect 301 /public/courses/.* /courses
How can I explain any link to .haccess file?
Please try following htaccess Rule. Make sure to place this rule top of your htaccess Rules file.
Please clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteRule ^public/courses/.*$ /courses [R=301,L]

htaccess rewrite url with same get parameters

I want to rewrite the url using .htaccess
Here is my main url which will be accessed by public:http://example.com/watch?v=123456789
I want same values of get parameters but in new location:
http://example.com/index.php?v=123456789
How can i do this? Help will be appreciated! Thanks.
it could be something like.. (.htaccess at root level)
RewriteRule ^watch/?$ index.php [QSA,L]
The important thing is the QSA option ("QueryString Append")
Hope it helps!

sub domain htaccess redirect to HTTPS URL

I've been trying to redirect my subdomain buynow.mydomain.info to the product link which is https://www.2checkout.com/checkout/purchase?sid=******&quantity=1&product_id=1.
I tried the simple .htaccess line
Redirect 301 / https://www.2checkout.com/checkout/purchase?sid=******&quantity=1&product_id=1
but it doesn't work, it only redirects to https://www.2checkout.com/checkout/purchase without mentioning my product as it ignores the rest of the URL ?sid=******&quantity=1&product_id=1
I thought it might be a problem with the link which is HTTPS, but I can't solve it, I hope you guys could help me, thanks.
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) https://www.2checkout.com/checkout/purchase?sid=******&quantity=1&product_id=1 [R=301]

.htaccess mod rewrite url

I would like to write a url from
Original URL
www.xyz.com/folder/articles?id=1221
to rewrite URL
www.xyz.com/folder/article-title-1221.html
Would this be possible? I am wanting to creates dynamic pages based on the id in the url.
Thanks in advance
Try this:
RewriteRule folder/article-title-([0-9]+)\.html$ folder/articles?id=$1 [L]

Resources