user1453559
user1453559

Reputation: 3

URL Rewrite querystring in htaccess

I've spent a couple of hours trying to achieve something I thought was easy. I have domain.tld/index.php?site=Page and want to turn it domain.tld/Page. The ?site=Page is relative to what it gets from the MySQL database.

At some point I had it make an endless loop, but everything else didn't effect anything. It might have something to do with, that I don't understand the ^ in RewriteRule and Cond. But the structure is /var/www/whine/skovtrup -- whine is the domain and skovtrup is a folder where I work with the website I need rewrite on. <Directory> is set to /var/www/whine in the sites-enabled file.

I really hope you guys can help me.

Just to sum up:

Upvotes: 0

Views: 1316

Answers (1)

zessx
zessx

Reputation: 68790

Will this code helps you ?

RewriteEngine On
RewriteBase /skovtrup/
RewriteRule ^index\.php$ %{QUERY_STRING} [C]
RewriteRule site=(.*) /skovtrup/$1? [R=301,L]

^ char represents the url start, and $ the end.

For my code, see some explainations here : Redirect old page url after .htaccess url rewriting

Upvotes: 1

Related Questions