Forum Moderators: phranque
[edited by: not2easy at 10:47 pm (utc) on May 1, 2017]
[edit reason] example/readability [/edit]
[edited by: not2easy at 2:29 am (utc) on May 3, 2017]
[edit reason] please use example.com for readability [/edit]
What i need all links like this ?page_id=99 (?page_id=98 or ?page_id=1) to be redirected to /page/
So, if there is any link (even from other website) to any page on your website - it will be better (faster) to setup 301 redirect
RewriteCond %{QUERY_STRING} .
RewriteCond %{REQUEST_URI} ^/(.*)
RewriteRule (^|/|\.html)$ http://example.com/%1? [R=301,L]
but don't copy and paste, because that's my site's version. The details of the pattern should be specific to your site. If the site uses parameters internally, but not in visible URLs, change the first Condition to RewriteCond %{THE_REQUEST} \?
And if you use extensionless URLs, and you never have . (dot) in directory names, the pattern in the RewriteRule might be best expressed as ^[^.]+$
The idea here is to keep the server from even looking at conditions when you already know they won't be met.