Tag Info

Hot answers tagged

3

To redirect everyone else, apart from your IP address (eg. 123.123.123.123), to the /blog subdirectory then you can use something like the following in .htaccess: RewriteEngine On RewriteCond %{REQUEST_URI} !^/blog/ RewriteCond %{REMOTE_ADDR} !=123.123.123.123 RewriteRule (.*) /blog/$1 [R=301,L] If the requested URI does not start with /blog/ and the IP ...


2

I may be missing something, but my first reaction is to not redirect (or rather internally rewrite?) if the file doesn't exist, but only when the URL does not already contain the version folder (eg. v01). For example, for .htaccess in the document root: # Internally rewrite to the latest version if not specified RewriteCond %{REQUEST_URI} !^/app/v\d\d/ ...


2

You would seem to have a couple of problems. You are trying to implement extensionless URLs, but (as per your comment) you have file.html and a subdirectory called file in the same directory. Because of this mod_dir is automatically adding the slash onto the end of the URL and your .htaccess directives are copying this slash into the substitution, hence the ...


1

Your regex code in general is wrong. Try instead something like this: RewriteCond %{HTTP_USER_AGENT} (.*Baiduspider.*|.*DV.*CRAWLER.*) [NC] You are matching against a string in each iteration between the parenthesis () separated by the pipe character | whereas .* is a wild card that matches anything. Optionally you can use \s or \s+ for spaces but .* ...


1

I'm sure there must be a more elegant/efficient way of writing this, but this should work to do what you require: RewriteEngine On RewriteBase / # Restrict users from IP address 10.8.0.11 to user1 sub-folder RewriteCond %{REMOTE_ADDR} 10\.8\.0\.11 RewriteCond %{REQUEST_URI} !(user1) RewriteRule ^(.*)$ /user1/$1 [L,R=301] # Restrict users from IP address ...


1

One way that comes to my mind would involve using PHP: $_SERVER['HTTP_REFERER'] You could check for the refering URL and implement a redirect accordingly: if($_SERVER['HTTP_REFERER']=="http://www.example.com/") { my_redirection_fuction(); } This is however a rather unreliable method since people can hide the refering url through browser privacy ...



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