Tag Info

Hot answers tagged

14

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


7

You need to drop the 'http:' prefix from all image (and any other) links on your site. When you do so, your browser will default to whatever protocol the page loads with. For example this is best: <a href="//www.example.com/"> And this is not: <a href="http://www.example.com/"> The top example is perfectly valid markup and you will load all ...


7

Empty Virtual Host With virtual hosting, all traffic is routed to an IP address and then Apache matches the hostname. When virtual hosting using NameVirtualHost is enabled, the site that responds to the IP address is the first one listed in the Apache configuration file. So you can use a null virtualhost: <VirtualHost 192.168.1.1:80> ...


5

First Step Open file as sudo vim /etc/apache2/apache2.conf Second Step remove comment sign (#) if you find it before this line ( line number 187 approx.) AccessFileName .htaccess Third Step Then find the line where there is <Directory /var/www/> Options Indexes FollowSymLinks AllowOverrideNone Require all granted ...


5

Although the browser should cache permanent redirects, I think an internal rewrite would be preferable. This avoids the browser having to make an additional HTTP request: RewriteEngine On RewriteRule ^([a-z]+\.css)$ /css/$1 [L]


5

No this is not good. Google did not intend for nofollow to be used for internal links. It is meant to be used for links that you do not have editorial control over. This is going to hurt you a lot. Your .htaccess code is not adding nofollow to your links. It is not possible for .htaccess to alter your HTML like that. Something else is causing your problem. ...


4

To block all "blank" User-Agents or User-Agents consisting of a hyphen, you could use the following in your .htaccess RewriteCond %{HTTP_USER_AGENT} ^-?$ RewriteRule ^ - [F]


4

You could just redirect /styles.css to /css/styles.css. In the .htaccess in the web root: RedirectMatch permanent /([a-z]+\.css)$ http://example.com/css/$1 (Replacing example.com with your real domain name.)


4

Activate mod_rewrite, and put this in a .htaccess file or a <Directory> directive: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_URI} !^apps/ RewriteRule (.*) apps/$1 What it does: The first three lines check if the requested URI refers to an actually existing file, ...


4

Regarding: "Is this ok?" No, its not good/intuitive for your users and hence not good for SEO. You should be using something like this www.alanmarth.com/ (Main Page) www.alanmarth.com/servicios (Services) www.alanmarth.com/blog (Recent news) www.alanmarth.com/blog/nameOfCategory2 (News category) www.alanmarth.com/blog/titleOfBlog3 (A single entry) ...


4

change your htaccess file code on resource server domain (i.e. The cdn htaccess; not the source calling the resource) <IfModule mod_headers.c> Header add Access-Control-Allow-Origin "*" </IfModule> This way domain2 is allowed to access resources on the cdn.


4

I’m not sure what the problem is in your case (I tested your snippet and it works as expected), but maybe this works for you: RewriteEngine On RewriteRule ^foo$ /redirect.html [redirect=temp,last] I’m not an .htaccess expert, but I guess this would even be faster, because the RewriteRule pattern gets processed before RewriteCond.


4

Use this. It should save you from two headaches. RewriteEngine On RewriteCond %{HTTP_PORT} 80 [OR] RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^(.*)$ https://example.com/$1 [R=301,L] this also allows any URL that starts with http://www.example.com/ or that connects to port 80 (the standard web port) to redirect to https://example.com/


3

A simpler one that also works: SetEnv no-gzip 1 The line you were using disables PHP's compression. The no-gzip env variable, on the other hand, disables Apache compression.


3

Check here: http://stackoverflow.com/questions/9249243/how-to-disable-apache-gzip-compression-for-some-media-files-in-htaccess-file It's possible, but looks like it will disable gzip for the whole website. Keep in mind that you are telling PHP not to gzip, but Apache may still be gzipping so this should sort it, but check Apache config. RewriteRule ^(.*)$ ...


3

You do not need a custom error document in order to monitor 404's on your site - if that is the requirement. All the information is in your server access log. The HTTP response code (ie. 404, 403, 200, etc) and the URL of the request that produced that response. The custom error document is a nice way of serving a meaningful response to users. You can also ...


3

I do not believe so. Not using ErrorDocument the way you have specified. Here is a resource site that seems to have some answers. http://www.askapache.com/htaccess/htaccess.html#Custom_ErrorDocuments Scroll down and you will find this example. If it is not exactly what you want, it can be modified. ### ALTERNATATIVE TO USING ERRORDOCUMENT # ...


3

I ran a quick test and got the following in my Apache access logs from adding an image to a Google Spreadsheet: 64.233.172.188 - - [09/May/2014:05:14:51 -0700] "GET twitter.png HTTP/1.1" 200 1842 "-" "Mozilla/5.0 (compatible) Feedfetcher-Google; (+http://www.google.com/feedfetcher.html)" 66.249.80.216 - - [09/May/2014:05:14:52 -0700] "GET twitter.png ...


3

Assuming you mean "subdirectory" and not "subdomain" (as per your examples), then try something like the following in the .htaccess file at x.com: RewriteEngine On RewriteCond %{REQUEST_URI} !^/sub/ RewriteRule (.*) http://y.com/$1 [R=301,L] Redirect (301) everything to y.com where the URI does not start with /sub/. Note that this redirects to the ...


3

Your syntax for Redirect is wrong. The first URL should be relative The second URL should be abolute Try this instead: Redirect 301 /gigs http://example.com/booking/


3

Something similar to the rewrite rules from Jon Lin's StackOverflow answer to Remove Characters from URL with htaccess should solve your problem. I would use this which should rewrite the URL to not have the characters, and then redirect: RewriteRule ^(.*)\'(.*)$ /$1$2 [L] RewriteRule ^(.*)\’(.*)$ /$1$2 [L] RewriteCond %{ENV:REDIRECT_STATUS} 200 ...


3

I think the following would work: RewriteRule ^/index\.php/rss/rss1klik$ /index.php?option=com_obrss&task=feed&id=2:rss1klik&format=feed&Itemid=160 [L] But this may look better: RewriteRule ^/rss/rss1klik$ /index.php?option=com_obrss&task=feed&id=2:rss1klik&format=feed&Itemid=160 [L] Then the URL would be ...


3

I would say yes, simply because there isn't any need for dynamic error pages. For example: If your database is down or under pressure, it is unlikely that you will want your error pages to be attempting database connections. Likewise, if your server is under pressure, you don't want your error pages to be carrying out any server-side processing. All-in-all, ...


3

This really depends on the error being served. For a 404 error, there would be no reason that there are any issues with the server - meaning all the php stuff should be working find. But if you have a 500 there may be an issue with the server, preventing php from running. This really depends on your tolerance for risk.


3

I was serving my static files using Django while my media files using Apache. Serving my static files through Apache solved this issue.


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


3

I have just discovered the solution! This seems to be a GoDaddy special. Domains in GoDaddy are kept in subfolders; e.g. mydomain.com might be held in a subfolder called md. Curiously, the start of %{REQUEST_URI} includes this string. Therefore, my RewriteCond should have read: RewriteCond %{REQUEST_URI} ^/md/foo$ It is not needed if the string does ...


3

Hey guys I finally figured it out, some how the code that works to do this in Modx CMS is below! This code shows you how to install it in a folder on your server. It tells the htaccess file to read the .html extension and loads up the page without a problem. #works, so happy!! # MODX supports Friendly URLs via this .htaccess file. You must serve web # ...


3

That should be: RewriteEngine on RewriteCond %{HTTP_HOST} !^www.domain.org$ [NC] RewriteRule ^(.*)$ http://www.domain.org/$1 [L,R=301] The "$1" tells mod_rewrite to add the matched text from inside the parentheses in the pattern to the rewritten URL, which is what you want.



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