Andrea Cazzola
Andrea Cazzola

Reputation: 127

Change a url with parameters using htaccess

Like on the title, I'm looking for a way to change a url with parameters (from this www.animevid.net/player/?anime=d/dmc to this www.animevid.net/player/anime/d/dmc) using the .htaccess file.

I've found many similar post but I've only got errors, loop redirect, or...nothing. The nearest thing i've got is this code :

RewriteRule ^player/([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+) player/index.html?anime=$1&t=$2 [NC,L]

Also please note the "d/dmc" on "?anime=d/dmc", is a variable, another example is "c/codegeass", "s/sao" etc...

Upvotes: 0

Views: 1065

Answers (1)

arkascha
arkascha

Reputation: 42885

As mentioned above the final, rewritten url you give as an example is invalid. You should escape the last /:

https://www.animevid.net/player/anime/d%2Fdmc

and rewrite to:

https://www.animevid.net/player/?anime=d%2Fdmc

Then you have to change your regex strategy for this to work. Try something like that:

RewriteEngine On
RewriteRule ^player/([^/]+)/([^/]+) player/index.html?anime=$1&t=$2 [NC,L]

Upvotes: 1

Related Questions