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

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


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

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

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

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


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

It looks to me like you would are trying to fetch data from a web service that is running on another port and display it using your main web server. mod_rewrite can be configured to do so. You have to have mod_proxy enabled and use [P] with your rewrite rules. Your directives might look like this: RewriteEngine on RewriteCond %{HTTP_HOST} ...


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


2

Google's bots will still want to request /robots.txt from your sub domain and not /robots_static.txt which would have no meaning to them. RewriteCond %{HTTP_HOST} ^www\.static\..*$ [NC] RewriteRule ^/robots\.txt$ /robots_static.txt [L] When requests for /robots.txt are made from your www.static domain the /robots_static.txt file will be served up as if ...


2

If you have mod_proxy available, you could proxy all requests forward to the subdomain through your .htaccess file with the [P] flag. <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)$ http://sub.example.com/$1 [P] </IfModule> Maybe not the best way (the best way would be to move all the files and reset any links properly), ...


2

Do not use robots.txt to remove pages unless there is a catastrophic emergency which this is not. The robots.txt file is not designed for this. It is designed to inform robots where they can and cannot go. The robots.txt file is generally not edited too often. In fact, many are not changed for years. If a page is removed and not replaced, a 410 error is ...


2

If you can SSH into your host log in and check the folder and file permissions on that sub-directory. they should be normal but may have gotten changed inadvertently. You can use .htaccess to define the default page but it doesn't sound like locating it is the issue here. Check that you have no other strangely named files. Try deleting everything in the ...



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