Tag Info

Hot answers tagged

7

You're right that the trick is a wildcard DNS entry (indicated with asterisk) . Essentially it's a DNS entry that will match all subdomains that don't have a specific DNS entry. Then the "routing" happens on the application/website side. There is no actual DNS entry created for the subdomain, the reason that it finds a "match" when a DNS request is made, is ...


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

Your server configuration seems to be correct. But you need to modify your mod_rewrite code. Remove leading / and make trailing slash optional by using /?$ in rewrite rule, so both http://example.com/2VMt2 and http://example.com/2VMt2/ URLs will work. RewriteEngine on RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?image=$1 [NC,L]


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

Are you running just the one site from Google Cloud? If you're using the default Apache config, on some distros it will set up one virtual host using the IP address as the name. Any other requests would be then diverted to that default virtual host, hence you end up at your IP address.


1

If you type in your domain, and it ends up on your IP, then that means it's being redirected. Look for a .htaccess file or a setting in Google cloud which is redirecting it. Perhaps Google cloud needs to be told what domain it will be serving for your IP? Use curl -I www.example.com to see the headers and redirects


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

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 ...


1

Not all server types allow using php_flag and php_value and for those server types you would need to add these directives in a php.ini file instead.



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