Reputation: 23
All I want to do is a very simple redirect so that mypage.html
is displayed in the browser, but index.php?s=1
is the page that is served up.
What am I missing here?
redirect 301 /mypage.html index.php?s=1
- this redirects the whole page as expected
RewriteRule ^/index.php?s=1$ mypage.html [R=301,L]
- this returns a 404 error when I access mypage.html
Upvotes: 0
Views: 62
Reputation: 15788
You wrote:
mypage.html
is displayed in the browser, but index.php?s=1
is the page that is served up.
If this is not a redirect you want to do (i.e. the URL in the client browser doesn't change) then you just have to make a rwriterule like this:
RewriteRule ^mypage\.html$ /index.php?s=1 [QSA,L]
Nothing more.
And now, if you want the user not to be able to type index.php?s=1
then add this rule:
RewriteRule ^/index\.php$ mypage.html [R=301,L]
So, all in all:
RewriteRule ^mypage\.html$ /index.php?s=1 [QSA,L]
RewriteRule ^/index\.php$ mypage.html [R=301,L]
Hope this helps
Upvotes: 0
Reputation: 18446
Do you want to redirect FROM mypage.html TO index.php?s=1?
If that is the case, you have your RewriteRule in the wrong order. It redirects you to mypage.html if you try to access index.php?s=1.
This shoud do the trick (no guarantees. I did not test the rule, just switched the filenames in your rule):
RewriteRule ^mypage.html$ /index.php?s=1 [R=301,L]
Upvotes: 1