Tag Info

Hot answers tagged

3

The goal would be to keep the redirects up as long as possible, ideally forever. Why? Users will have bookmarks with the old URLs and other websites will have links to the old domain. These may never go away and you would like to keep them working if at all possible. That's just good usability (i.e. a good user experience). You could easily accomplish this ...


3

From the mod_rewrite documentation you need to use the NE (no escape) flag when your rewrite rule has a hash: RewriteRule #(.+)$ /? [L,R=301,NE] You commented that the NE flag may only apply to the target URL and not the rewrite pattern. If that is the case, another approach would be to escape the # sign. mod_rewrite supports \x style escape sequences. ...


2

If your subscribers have to login to your website, then you could use a PHP script in your images folder to check that they are logged in before serving an image in the same way you would check this before serving them a subscriber-only webpage. Your .htaccess file might have: # Protect subscriber-only assets from hot-linking (*.gif) RewriteCond ...


2

In this case, where you are already rewriting the "pretty" URL to the "ugly/real" URL you can redirect the ugly URL to the pretty URL by checking against THE_REQUEST. This contains the original HTTP request, before any rewriting has occurred. Otherwise you are in danger of creating a rewrite loop when you rewrite back to the ugly URL. For example: ...


1

Try something like RewriteRule ^([en|es|ru|de]{2})/(.*)$ $2?lang=$1&%{QUERY_STRING} [L,QSA] Where you'll want to replace [en|es|ru|de] with the all valid 2-letter language codes your site uses. This will then take whatever is after the language-code in the URL, and use that as the "main" URL, and then effectively append ?lang=es to the "actual" URL, ...


1

I think the problem with your rewrite rule is the OR flag. That flag usually means that there is a second rewrite condition coming. You only have one condition. Here is a site that provides a similar rule for blocking BaiduSpider with slightly different syntax: RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^Baiduspider.* [NC] RewriteRule .* - [F]


1

You can try blocking specific IP addresses in your .htaccess file. You can find the ranges here. In robots.txt you can also add the following User-agent: Baiduspider User-agent: baiduspider User-agent: Baiduspider+ User-agent: Baiduspider-video User-agent: Baiduspider-image Disallow: / Also, if you use caching plugins or CDN, make sure to clear all your ...


1

Once added the mod_rewrite rule in .htaccess it works regular as active , so you can add and use it . You can also ask your hosting company to enable mod rewrite rule for you in server that is much better for you


1

You can't create a subdomain using only PHP application. First you need to configure apache virtual host to accept requests for multiple domains. <VirtualHost *:80> ServerName www.example.com ServerAlias example.com *.example.com DocumentRoot /www/domain </VirtualHost> With wildcard subdomain *.example.com, main domain will ...


1

HTTP_COOKIE is a semi-colon delimited list of all the cookies that are set. Your == test would only work if your cookie were the only one set. Instead, I would try this regular expression match in the <If> directive: <If "%{HTTP_COOKIE} =~ /XDEBUG_SESSION=leho/">


1

Thanks to the hint of Max and this post, I found the answer to my problem: RewriteEngine On RewriteCond %{HTTP_HOST} !^$ RewriteCond %{HTTP_HOST} ^mydomain.com [NC] RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


1

You will have one problem that you will need to address so I will cover it first. You will have trouble with duplicate content using the method you suggest. On each page, you can have either HTTP point to HTTPS content or the other way around. Adding this to the header of each page, obviously modifying the example URL on a case by case basis, then you ...


1

OK, same here, and a update on Prashant's great solution. I use 2 virtual Servers, one with my Wordpress and a cookieless Vserver as CDN. The .htaccess-Code from prashant needs to be in the cookielss domain's .htaccess-file, because one of the delivered CSS-Commands points to the primary domain, where it triggers that error. BTW: I think it is wrong coded ...



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