ntsu
ntsu

Reputation: 67

Redirecting a URL that contains a specific part to another URL using htaccess

I would like to know if there is a way to redirect a URL that looks like this:

https://www.example.com/p=d3d82c7c

to

https://www.example.com/polls/poll?poll=d3d82c7c

using htaccess.

What I want to do is to create a more simple link for the users. Is that possible with htaccess only?

PS: the code at the end may change within each URL.

Thank you very much.

Upvotes: 2

Views: 124

Answers (2)

RavinderSingh13
RavinderSingh13

Reputation: 133538

With your shown samples, could you please try following. Please make sure you clear your browser cache before testing your URLs.

RewriteEngine ON
RewriteRule ^.*=(.*) polls/poll?poll=$1 [L]

OR with your shown samples if your URI always starts with p then you could try following, but make sure either previous OR this only one of them should be used at a time.

RewriteEngine ON
RewriteRule ^p.*=(.*) polls/poll?poll=$1 [L]

Upvotes: 3

slckKadeR
slckKadeR

Reputation: 57

You can use this method:

Redirect 301 /en/php/project.html http://www.example.org/newpage.html

Upvotes: 0

Related Questions