0

I know there are a few of these, but I can't find one that describes what I want to do.

I've got an page that I want to retire, for example:

www.mysite.com/pages/page_old.php?someargs

I'd like the _old to be stripped off, so the page goes to

www.mysite.com/pages/page.php?someargs

I've tried

RewriteEngine On
RewriteBase /
RewriteRule ^/pages/page_old.php$ ^/pages/page.php$ [L,R=301]

but it doesn't work.

Worth noting that ?someargs can be any args passed to the page, so this must be flexible.

1 Answer 1

1

The leading slash is not at the URI-path tested in the rule, so it can't be in the regex either.

The substitution URL is a plain text string and regular expression characters shouldn't be used as they are passed literally.

You may try this instead:

RewriteRule ^pages/page_old.php  /pages/page.php [R=301,NC,L]

The query string will be passed through unchanged to the substitution URL

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for that, it's still not forwarding though.
Please make sure the browser's cache is cleared and post the testing URL. It should work. You can see the substitution URL, could you please post it too?
Where is the .htacces file?
it's an intranet site, so can't post that. the .htaccess is in the root folder.
ah, I've properly cleaned the cache and it's worked (shift+f5 in Chrome wasn't working).

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.