0

how change parameters of url with htaccess

I have 2 url like this:

1- example.org/?ptype=writer/5/jon-sina   
2- example.org/?ptype=publisher/10/ali-ssadeghi

I want to redirect that 2 address to these:

1- example.org/?ptype=product/5/jon-sina  
2- example.org/?ptype=product/10/ali-ssadeghi

*

I wanna just change "writer" and "publisher" to: "product"

*

help me plz :)

1 Answer 1

3

add the following directives to your .htaccess :

RewriteEngine on
RewriteCond %{QUERY_STRING} ^ptype=(writer|publisher)(.*)$
RewriteRule ^(.*)$ $1?ptype=product%2 [R=301,L]
Sign up to request clarification or add additional context in comments.

1 Comment

tanks :) it solved my problem but i have new problem with this. this is my url : localhost/mysite/?ptype=publishers/12/ali-joon so i have to redirect to this: localhost/mysite/?ptype=product/12/ali-joon but htaccess redirect me to this page : localhost/?ptype=publishers/12/ali-joon my site is deleted :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.