Using regular expression in htaccess for 301 redirects
Using mod_alias: RedirectMatch 301 ^/news/(.+?)(-[0-9]+)?$ /blog/$1 or using mod_rewrite: RewriteEngine On RewriteRule ^news/(.+?)(-[0-9]+)?$ /blog/$1 [L,R=301]
Using mod_alias: RedirectMatch 301 ^/news/(.+?)(-[0-9]+)?$ /blog/$1 or using mod_rewrite: RewriteEngine On RewriteRule ^news/(.+?)(-[0-9]+)?$ /blog/$1 [L,R=301]
You could use proxy_redirect directive: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect Nginx will still return 301/302 to the client but proxy_redirect will modify Location header and the client should make a new request to the URL given in the Location header. Something like this should make the subsequent request back to nginx: proxy_redirect http://upstream:port/ http://$http_host/;
I know this is an old question but the answers don’t really address the primary issue that was presented in the question which is a 301 redirect for SEO purposes (and the answer today may very well be different than it was when the question was originally asked and answered). The answer that no, you … Read more
You could use a rewrite rule with a query string match condition, such as: RewriteEngine On RewriteCond %{REQUEST_URI} ^/index.php$ RewriteCond %{QUERY_STRING} ^page=news&id=2366$ RewriteRule ^(.*)$ http://www.example2.com/news.php?name=23546 [R=301,L] Checkout this blog page for more information on how this works.
Redirect 301 /Blog /blog Or use something like http://www.htaccessredirect.net/index.php
If you are using the R flag you are telling mod_rewrite that an external redirect is what you want, therefore the browser is asked to make a new request and the address bar should change accordingly. Without the R flag, there is no redirect, but an Apache-internal request rewrite which is hidden from the browser. … Read more
RedirectMatch uses a regular expression that is matched against the URL path. And your regular expression /contact.php just means any URL path that contains /contact.php but not just any URL path that is exactly /contact.php. So use the anchors for the start and end of the string (^ and $): RedirectMatch 301 ^/contact\.php$ /contact-us.php
An overview of 301, 302 and 307 The RFC 7231, the current reference for semantics and content of the HTTP/1.1 protocol, defines the 301 (Moved Permanently) and 302 (Found) status code, that allows the request method to be changed from POST to GET. This specification also defines the 307 (Temporary Redirect) status code that doesn’t … Read more
Status 301 means that the resource (page) is moved permanently to a new location. The client/browser should not attempt to request the original location but use the new location from now on. Status 302 means that the resource is temporarily located somewhere else, and the client/browser should continue requesting the original url.
Using a 307 should be exactly what you want 307 Temporary Redirect (since HTTP/1.1) In this case, the request should be repeated with another URI; however, future requests should still use the original URI.[2] In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original … Read more