Pankaj Khairnar
Pankaj Khairnar

Reputation: 3118

.htaccess redirect/rewrite help needed

I am writing htacess redirect rule but it is not working properly I have tried many solutions but simply it is not working.

What I want to do is to I have url http://example.com/cms/index.php?page=filename I want this url to be executed and show appropriate page but in browser it should show example.com/cms. And what is important is I only want to right this rule for this page only and it should not effect to other pages.

Thank you.

Upvotes: 1

Views: 139

Answers (2)

Jon Cage
Jon Cage

Reputation: 37516

Something like this ought to work:

RewriteEngine on
RewriteRule ^http://example.com/cms$ http://example.com/cms/index.php?page=filename

...should work.

Have a look at a tutorial with some examples if you're interested in seeing what else you can do.

Upvotes: 1

Meep3D
Meep3D

Reputation: 3756

RewriteRule ^([^/]+)/$ /cms/index.php?filename=$1 [L,QSA]

The L at the end says it is the last rule (stop processing) and QSA means 'Query String Append', so if someone puts other parameters after it, such as:

http://example.com/cms.htm?order=desc

The GET value for order will be passed also - without it it'll just quietly drop it.

Upvotes: 2

Related Questions