New answers tagged

1

You'll need to use mod_rewrite (as opposed to a mod_alias Redirect) and check the HTTP_HOST server variable (which tells you which site has been accessed). Something like the following at the top of your .htaccess file: RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?website1\.com$ [NC] RewriteRule ^example/(.*)$ http://www.website2.com/example/$1 [R=302,...


1

It's been a long time since I've used Apache and I don't use PHP but ... You can set your own HTTP headers, redirect, and just about everything else within a programming environment that doesn't block you from accessing those files. I don't recall where in the flow .htaccess is looked at when PHP pages are executed but you would need to find out, by ...


8

...in case the webhoster disabled the use of .htaccess files? If the webhost has disabled the use of .htaccess files then there is no direct alternative. (.htaccess = per-directory Apache config file) .htaccess files are not necessary if you have access to the Apache server config. In fact, it is preferable to use the server config instead of .htaccess ...


1

As far as I know, there are no alternatives. Seems this topic was discussed from another angle : Alternative to .htaccess (due to bad performance?)


-2

You can add the below code into your site's .htaccess file to fix this issue: # Redirect non-www to www: RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


-1

You could also just install the excellent WP Redirect plugin that will make for a quick fix.


3

In order to match the query string (ie. page_id=123 part) you need a RewriteCond directive and the QUERY_STRING server variable (from mod_rewrite). Try something like the following in the /abc/.htaccess file (ie. in the subdirectory you want to redirect from): RewriteEngine On RewriteCond %{QUERY_STRING} ^page_id=123 RewriteRule ^$ /xyz/newindividualpage/ [...


1

I've started using the following code: RewriteCond %{HTTP_REFERER} ^http://.*[bad_referrer]\.com/ [NC] RewriteRule ^(.*)$ – [F,L] This looks for the referrer, in your case semalt.com, and creates a bad request. If you want to add more conditions use [NC,OR] until you get to the last item. If mod_rewrite isn't available, this technique will not work. You ...


1

This isn't a direct answer to your question but to your problem: Try a hostname filter on your Analytics account instead. Filter only for your domain. The only situation in which you'll get views without your domain being the hostname is if you're serving content on other domains - such as via an iFrame. When it comes to crawlers, there's many techniques. ...


0

I know this old but I just came across it. If you're using WordPress.org, you could use Google Breakdance add-in. If you're using asp.net, you'll have to convert the Apache script to URL Rewrite XML. However, I've been using the IIS method and I think Google now no longer like it and have penalised my site. I've got back to the old image hotlinking ...


0

Because you mentioned this is for a LAMP server and you have SSH access, you can do this quite simply with a 000-default VirtualHost like this, (changing example.com to your domain): <VirtualHost *:80> Redirect permanent / http://www.example.com/ </VirtualHost> Rewrite methods are unnecessary, and redirecting provides better security ...


1

Here are some redirect options you can use in .htaccess. These cover various cases of raw IP, the IP somehow mucked with www, util host subdomain (for addon domain), target www mode, target HTTPS mode, etc. This will also preserve any URi's instead of just dumping to a static homepage or whatever. Swap/edit the last 2 lines for www and HTTPS mode: ...


1

If you do not want the site to respond to the IP Address I would implement a virtual host in Apache. Set the virtual root to a different directory of the Apache server. Now all traffic defaults to a different location of your manned site. Otherwise as already noted I would use a redirect. Personally I would use the htaccess style. After tested in the ....


1

Easy. Just make a redirect from the IP address to the domain name. Method 1 A nice way to do it if your server supports it is to create a PHP file containing the following: <?php header("HTTP/1.1 301 Redirect",true); header("Location: http://example.com",true) ?> <html><head><title>Redirect</title><body> <a href="...


1

See the following from CloudFlare: How do I fix the infinite redirect loop error after enabling Flexible SSL with WordPress? Some users may experience redirect loops after activating CloudFlare’s free Universal Flexible SSL option. In order to fix this issue and/or get things set please follow the steps outlined below: ** WordPress Site ** 1. Install ...


0

the "Too many redirects" issue comes from the fact that redirects are tied together. For example, http://example.com redirects to https://example.com and https://example.com redirects back to http://example.com. This process can repeat itself over and over again until the redirect count established by the server is reached, then when that is exceeded, the ...


0

Using mod_rewrite in the .htaccess file in the document root: RewriteEngine On RewriteRule ^(.+/)?old-(.*) /$1$2 [R=301,L] This will handle old- files in the document root and anywhere on the filesystem (not explicitly stated in your question, but the other answers assume these files are all located in the document root). It assumes that abc.php is in the ...


1

In the .htaccess file where competition.example.com points to on the filesystem, you can use a mod_alias Redirect: Redirect 301 /option_1 /option_2 This assumes you don't have any existing mod_rewrite (ie. RewriteRule) redirects that might conflict. Note that .htaccess files inherit along the filesystem path (regardless of whether you are using ...



Top 50 recent answers are included