1

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,

2 Answers 2

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]
Sign up to request clarification or add additional context in comments.

1 Comment

Hey thanks for the really useful response. I found some answers at: klauskomenda.com/code/rewrite-rules-practical-examples
1

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.

Comments

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.