Eamorr
Eamorr

Reputation: 10022

Apache2: rewrite query string

I have the following url:

http://www.mysite.com/blog.php

and I want it to rewrite to:

http://www.mysite.com/index.php?goto=blog

How to do this in Apache2?

I've seen many examples of doing it the other way around...

Many thanks in advance,

Upvotes: 1

Views: 86

Answers (2)

Alberto De Caro
Alberto De Caro

Reputation: 5213

Try this (untested):

^/(.*)\.php$ /index.php?goto=$1

This should work even with other pages, not only with the blog.php. Have a look at the documentation.

Upvotes: 1

If you want to rewrite all .php to index, you should do:

RewriteRule ^(.*).php$ index.php?goto=$1 [L,QSA]

if you would like to rewrite only some files:

RewriteRule ^(blog.php|other_file.php)/(.*)?$ index.php?goto=$1/$2 [L,QSA]

Upvotes: 1

Related Questions