Hot answers tagged

10

You can make any file dynamic. The best way to do so is not through redirects, but through rewrite rules. RewriteRule ^robots\.txt$ /robots.php [L] That way, you power it with a dynamic script, but the URL doesn't change. Most crawlers (including Googlebot) will follow redirects for robots.txt, but some crawlers will get confused if you introduce ...


6

Splash screens are acceptable according to Google. They do offer some best practices however, when using multi-language/multi-regional sites. In this article, Google recommends the use of the hreflang tag within <link rel="alternate" ... /> tag in the head. The specific excerpt from the article is below: For language/country selectors or auto-...


6

Will the submitted data be secured and encrypted normally? Yes, when the data is submitted from HTTP to HTTPS (via the form's action attribute), the data will be sent via an encrypted connection. However, the user will probably be unaware of this, so the "user trust" that HTTPS provides is non-existent. ...that redirects back to HTTP? The redirection ...


5

Yes, the same way any request can be "dynamic". However, you would not redirect (as in your example code), you should internally rewrite using mod_rewrite. (The same as what Drupal is probably already doing.) For example, in your root .htaccess file: RewriteEngine On RewriteRule ^robots\.txt$ robots.php [L] RewriteEngine should only occur once (although ...


5

This is not secure (but better than posting to HTTP). The data will only be encrypted in cases where no man-in-the-middle attack is undergoing, but of course one of the reasons for offering HTTPS is the assumption that such MitM attacks could happen. Attackers will be able to tamper with your HTTP page. They could, for example: change the form-action URL ...


5

You can't do a simple redirect of "all articles" if the source and destination IDs in the URL are different and there is no easy way to map between the two. For example, how do we know that 966aaafd8 maps to 8a4521384? In order to do this you would need to create a RewriteMap in your server config (containing all the source / destination IDs) or rewrite ...


5

What seems to be happening, is your rule is being matched and then apache is sending a 301 redirect response telling the browser to generate a new request for /web-browser-benchmarks-firefox-chrome/ Chrome is generating this request - as instructed, but when your webserver see's this new request - your rule is matching that request too - again telling ...


5

Well aren't you friendly... "Hey Google, I'm having a DOS, but im making it your problem, thanks" First: There is no difference for you between serving an 301 or an 404 error page. Your server will have to do the same amount of work. The difference here is that you, with your 301->google solution, now ALSO make it Google's problem, effectively doubling ...


5

I would very much like to use wildcard redirects where possible (like in the directory structure that contains 2,000 MP3 files). If your server software is apache, then you can use the rewrite module to redirect some URLs to others using wildcard character sequences in the regex. For example, to redirect http://example.com/apple1, http://example.com/appleA,...


4

You can make a 302 - temporary redirect. Example in PHP: header("Location: /product/list", true, 302); // temporal redirect The browsers requests the /home url, gets status 302, new url: /example back from the server. Your browser now says "Oh ok, I'll now open /example for now". Bots understand the redirect; the 302 makes them understand this is ...


4

The POST request will be protected by SSL, but there are other problems to think of: When switching between HTTP and HTTPS it is easier to do an SSL-Strip attack. The session id will be sent to HTTP requests too and therefore can be sniffed easily. It is surely a good idea to switch to HTTPS for the whole site, but if that is out of question, then you ...


4

Just because a URL is in Google's index doesn't mean that it was submitted through webmaster tools or search console. Google includes most URLs in the index only because it finds links to them on other sites. Most of the time Google won't index a redirecting URL (including a shortened URL.) Usually Google prefers the destination. If the redirect URL ...


4

It's called adaptive web development. You need to detect the user-agent and serve different markup based on the device. In PHP, you can use $_SERVER['HTTP_USER_AGENT']. You'll want to include this code in order to let Google know what you're up to: <?php Header('Vary: User-Agent'); ?> Here's some more info: https://developers.google.com/...


4

# Use PHP5.4 as default # Changed PHP handler from application/x-httpd-php54 to application/x-httpd-phpbeta on Thu Dec 17 16:50:26 MST 2015. AddHandler application/x-httpd-phpbeta .php # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # Insert redirect based rewrites here. # Example: RewriteRule ^redirectme$ ...


4

The domain authority on expired domains comes mostly from the inbound links to their deep pages. If you have similar enough content that your domain can satisfy the users that click on those links then you might get some SEO benefit from the domain redirect. To get it, you would have to put appropriate redirects in place. For example if you find a link ...


4

You should probably implement a rel="canonical" element in the head section of the old content that points to the new content. For example: <link rel="canonical" href="http://example.com/new-page"> This informs the search engines that the /new-page is preferred and should be returned in the search results instead. Note that this is advisory, so if ...


4

Absolutely. Your .htaccess file is located in the root directory of the website and can be accessed via FTP.


4

On a WordPress site WordPress uses mod_rewrite to handle the URL routing (pretty URLs) - which I assume you are using - so you should avoid using a mod_alias redirect (Redirect, RedirectMatch, etc.) in this instance. (Different modules run at different times, regardless of the order of the directives in the .htaccess file, so you can get unexpected results/...


3

This assumes that p, id or catid always appears at the start of the query string, and that the value of this parameter is the "file" basename in the new URL, as per your code examples. RewriteEngine On RewriteCond %{QUERY_STRING} ^(p|id|catid)=(\d+) RewriteRule ^$ /%2.php? [R=301,L] The ^$ pattern only processes requests for the document root (ie. example....


3

You want to do a blanket redirect from one domain to another. Assuming Apache, put in your .htaccess file in the root directory of example0.com: RewriteEngine on RewriteRule ^(.*)$ http://www.example1.com/$1 [L,R=301] This will redirect all requests from 0 to 1 and keep the original request URI.


3

Redirection is the process of forwarding one URL to a different URL. There are three main kinds of redirects: 301, 302, and meta refresh. Types of Redirects 301, "Moved Permanently"—recommended for SEO 302, "Found" or "Moved Temporarily" Meta Refresh A redirect is a way to send both users and search engines to a different URL from the one they originally ...


3

RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [R=301,L] Yes, that line removes a trailing slash from the URL. However, you would need a condition before that to prevent a rewrite loop if mod_dir (DirectorySlash) is active and you are requesting a filesystem directory. And that's probably the problem here. If you request /directory, where "directory" is an ...


3

Your redirects for users without cookies are a bad idea. Googlebot never sends cookies, but Google has data centers around the world. When Googlebot crawls from a data center in France, it won't be able to get to your English website and your English website could get dropped from the Google index. Location based redirects are also problematic for real ...


3

In each language-specific page, ensure you have the language set. Either use the <meta http-equiv="content-language" content="ll-cc"> tag in the section of your page, where "ll-cc" stands for the culture code of the language and country/region the content applies to, or use the lang="ll-cc" attribute on either the <html> or the <title> tag ...


3

Having a single URL for each page is known as URL Canonicalization. Canonicalizing the URL for each page has been an SEO best practice for ten years or more. The search engines won't think badly of you for redirecting your short URLs to your long URLs, doing so may even improve your rankings. This StackExchange site implements redirects for ...


3

Redirect original community.example.com posts to example.com You'll still need to keep the subdomain alive in order to redirect any requests (otherwise it simply won't resolve). This is just a redirect everything. In either the .htaccess file at community.example.com or the main .htaccess file at example.com (or your server config) you can do something ...


3

It is fully normal, that traffic drops after such basic change of URL structure. Google needs time to get the new structure, to re-index pages, to understand, whether the content changed and so on. I would say, the drop time is from 1 up to 5-6 weeks long. But you can speed up the re-indexing with new sitemap and new content, which is backlinked externally.


3

After some trys and searches I got it working using: RewriteCond %{DOCUMENT_ROOT}/$2 -f [OR] RewriteCond %{DOCUMENT_ROOT}/$2 -d RewriteRule ^([a-z]{2})/(.+)$ /$2 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [L]


3

This is a great idea, when handled properly. You need to to some research about domains first Verify that there is not Manual Penalty to this domain (Verify it through Google Webmaster Tool ) Check the back-links of domain if any. It might be victim of Penguin 2 & 2.1 (You can use ahref.com for example) Redirecting domains without above ...


3

If you're going to move to HTTPS, the right kind of redirect to use is a 301 redirect, which says you've moved the page permanently to a new spot. About the use of 301 redirects when moving to a new domain, Google says the following: If you can do those [301] redirects to do the granularity of page level to page level, that's a great user experience. ...



Only top voted, non community-wiki answers of a minimum length are eligible