php - Mod_Rewrite: Testing URL got indexed in Google - How do I create a proper 301 redirect? -


I worked on a website for which I had a "development URL" that looked something like this:

www.example.com.php5-9.dfw1-2.example.com /

Now, several weeks after the start of the website, at least one of the content The page is indexed on Google with that URL

Question: How can I redirect all requests from that test URL to route the actual domain again?

For example, I want to:

www.example.com.php5-9.dfw1-2.example.com/page-name

To go to:

www. Example.compage-name

The website is powered by WordPress and is hosted on the PHP server. I have experimented with .htaccess without success.

If www.example.com be the only valid host name on your server You can use this rule to emphasize this host name:

  RewriteCond% {HTTP_HOST}! ^ (Www \ .example \ .com |) $ rewrite% {HTTPS} s ^ s (s) | RewriteRule ^ http% 1: //www.example.com% {REQUEST_URI} [L, R = 301]  

Otherwise try redirecting this rule to this specific host name:

Revoked% {HTTP_HOST} = www.example.com.php5-9.dfw1-2.example.com Remit Conduit% {HTTPS} s ^ on (s) | RewriteRule ^ http% 1: //www.example.com% {REQUEST_URI} [L, R = 301]

You can check the request method in additional REQUEST_METHOD This rule will match any method (as well as post).


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -