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

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

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

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

The type of redirect you are using is not the problem. 301 redirects are cacheable. In fact they are extremely hard to cache bust. 301 means "permanent" and browsers are very likely to cache 301 redirects with no way with the server to undo one that is already cached. 302 redirects are generally not cached by default unless other headers indicate that ...


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.


3

You need to know the relationship between the project-folder and the sub-folder, ie. which sub-folder a particular project is in. If there is no pattern between project-folder and sub-folder and being restricted to .htaccess then I think you'll need to specify each rewrite manually. You can internally rewrite all requests for the respective project to ...


3

While it isn't impossible to host multiple secure sites on a single IP address, thanks to SNI and SAN, the redirect you're trying to do is impossible without one of the aforementioned solutions. In order to receive a redirect from https://www.olddomain.com, the browser must have already requested that URL using SSL/TLS, and is expecting an encrypted response ...


3

You can just add another RewriteCond directive: RewriteCond %{REQUEST_URI} !^/activity RewriteCond %{REQUEST_URI} !^/members RewriteRule ^(.*)/([0-9]+)/$ /$1/S$2/ [R=301,L] Multiple RewriteCond directives are AND'd together by default. The OR flag can be used if required. I've removed the NC flag - unless you specifically need a case-insensitive match. As ...


3

You can do this by adding another condition. RewriteCond %{REQUEST_URI} !^/members [NC] RewriteCond %{REQUEST_URI} !^/activity [NC] RewriteRule ^(.*)/([0-9]+)/$ /$1/S$2/ [R=301,L] Or, sometimes simpeler, use the OR of a regex: RewriteCond %{REQUEST_URI} !^/(members|activity) [NC] RewriteRule ^(.*)/([0-9]+)/$ /$1/S$2/ [R=301,L] I've removed the .*$ ...


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


3

The space is a delimiter (ie. a special character) in .htaccess so must be backslash escaped if you want to match a literal space in the regex. Eg. DV\ CRAWLER. (Otherwise you are likely to get a less than helpful 500 Internal Server error.) Or, you can use the shorthand character class \s which matches any white space character (space, tab or new line / ...


2

By default the query string on the requested URL is appended to the rewritten/redirected URL. The easiest way to remove the query string from the redirected URL is to simply append a ? at the end of the RewriteRule substitution. This essentially writes a blank query string (the ? does not actually become part of the rewritten URL). So, from your example: ...


2

Your root .htaccess should look like this: # Mod RewriteRules, some 12 in all RewriteRule ^mod/(.*)$ /moderator/$1 [NC,L] RewriteRule ^signup/(.*)$ /acc/signup/$1 [NC,L] RewriteRule ^signin/(.*)$ /acc/signin/$1 [NC,L] RewriteRule ^signout/(.*)$ /acc/signout/$1 [NC,L] # These are the only two that a front end user will use # category/subCategory ...


2

You can use these three rewrite rules which handle up to 3 levels of directories: RewriteEngine on RewriteRule ^main\/([^\/]+)\/([^\/]+)\/([^\/]+)\/? /parser.php?var1=$1&var2=$2&var3=$3 [L] RewriteRule ^main\/([^\/]+)\/([^\/]+)\/? /parser.php?var1=$1&var2=$2 [L] RewriteRule ^main\/([^\/]+)\/? /parser.php?var1=$1 [L] In those regular ...


2

I suspect you are over thinking this. I am really confused over all your code. One of the things I am finding these days is that people are using example code that is already unnecessarily complicated. As well, people seem to select {???} that offers too much instead of the narrowest selection. Often these things only require 2 lines or 3 at the most and ...


2

If your .htaccess has RewriteRules like these: RewriteRule page.html /another-page.html [NC,R=301,L] It will always remove querystring parameters, that's default behaviour. You'll have to add QSA flag to your RewriteRule, like this: RewriteRule page.html /another-page.html [NC,QSA,R=301,L] Apache mod_rewrite doc QSA|qsappend


2

You could simply redirect the user to the named host: # Uncomment the line below if not previously added in the file # RewriteEngine On # Rule to redirect to the named host # Replace [xx.xx.xx.xx] woth your host's IP address # Replace [yourdomain.com] with your host's proper URL RewriteCond %{HTTP_HOST} ^xx\.xx\.xx\.xx$ RewriteRule (.*) ...


2

This may not really be an answer to your question, but the best way to make a multilingual is in most cases by using some simple PHP. Create a folder called languages and create the files lang.code.php. Replace code with, for example EN for English, DE for German, etc. Create a language switcher with the following code: <?php $lang = "en"; if( isset( ...


2

Triying the same and on my search I found that symfony2 frameworks .htaccess file is doing that at least it is stated in the file that it would. I tried to use it in my own setup but didnt work. Maybe that will help you guys somehow. # Determine the RewriteBase automatically and set it as environment variable. # If you are using Apache aliases to do mass ...



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