Tag Info

Hot answers tagged

1

The source of your problem can be in html or in javascript, and you cannot control the links that other people put on the net too.. And because he finds a page when making a request for it, it indexes it. I miss some information to give answer with code (using a CMS? Other rules in .htaccess, etc…), but here are some ways : Write a permanent redirect in ...


1

I think the problem here is not to do with your .htaccess redirections, but to do with your VirtualHost configurations in Apache's httpd.conf configuration file - this is how Apache knows which folder to direct requests to for processing. # Default Site - Blank <VirtualHost *.80> ServerName localhost DocumentRoot /var/www/default ...


1

The %{THE_REQUEST} contains the full HTTP request header sent by the browser, not simply the URL. If you examine this value, you will see that for the second (short) URL, THE_REQUEST does in fact contain 3 forward slashes after the word "article" (although not necessarily part of the URL itself) and so matches the pattern. The request line is probably ...


1

So after some trial and error I came up with a working solution that I'm not quite happy with. But at least it works. Since all "real" images are located in /includes/ or subdirectories I simply rewrote the rule for the images. So this location ~* \.(?:gif|jpe?g|png|ico)$ { expires 168h; add_header Pragma public; add_header Cache-Control ...


1

You should really solve this by setting the DocumentRoot correctly on your local test server. Perhaps setup a VirtualHost for this test site, rather than changing your default server config if you are testing several sites? It is a local test server, so should reflect the settings of the live site as close as possible. However, it is possible (but not ...


1

It is not exactly the answer to your question but you should think twice about removing trailing slashes for directories. The doc about DirectorySlash warns from potential problems (a mess with relative urls and others). And you can save some headaches by only redirecting with a 301 /dir/index.html to /dir/ (nearly your point 3), and using DirectoryIndex ...


1

Aren't your last two entries cancelling each other out? # Redirect /foo to /foo/index.html then the other way # Redirect /foo/index.html to /foo If it just for those individual files? Then I'd try: # 301 Redirect /foo/index.html to /foo RewriteCond %{QUERY_STRING} ^$ RewriteRule ^foo/index\.html$ /foo? [R=301,NE,NC,L] # 301 Redirect /foo/ to /foo ...


1

Problem was a WordPress one. It was stripping out the @ when re-writing the non www address to the www address. Problem resolved by adding my old redirect code (which I thought I could dispense with) to top of the .htaccess file: RewriteCond %{HTTP_HOST} ^example\.com$ RewriteRule (.*) http://www.example.com/$1 [R=301,L]


1

You might be able to resolve this by using the NE (noescape) flag on the RewriteRule directive? However, this is admittedly a little puzzling, as even special characters shouldn't be removed entirely, just converted to their hexcode equivalent. The NE flag allows special characters to be passed through untouched. However, your current rules can be greatly ...


1

Try this in your .htaccess inside your subfolder: RewriteCond %{HTTP_HOST} ^www.example.com [NC] RewriteRule (.*) http://example.com/blog/$1 [R=301,L]


1

change your htaccess file code <IfModule mod_headers.c> Header add Access-Control-Allow-Origin "*" </IfModule> when you write Header add Access-Control-Allow-Origin "http://skin.cdn.com" this, you can only access this domain. not http://domain2.com. * this allow you to all domain.


1

It should just work fine provided that the URL is enclosed in double-quotations, for example: Old URL: http://www.example.com/folder%20name/page%20name.html New URL: `http://www.example.com/folder/page Redirect 301 "/folder/page%20name.html" http://www.example.com/folder/page


1

I see some problems with your rewrite rules. You don't explicitly turn on mod_rewrite with RewriteEngine On When using rewrite rules in your .htaccess file the slash at the beginning of them is assumed. Having a slash at the beginning of the rule will prevent rewrite from executing the rule. (This is different than if the rule were in httpd.conf where ...


1

Apache doesn't recommend using domains in the <VirtualHost> declaration, I have found from experience that you will have far less trouble using an asterisk here (*) and just let the domain be matched against the ServerName value. Also, the first virtual host site behaves as a default for whenever the name does not exactly match one of the defined ...


1

Yes, we used to filter visitors from Nigeria by .htaccess: RewriteEngine On RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^NG$ RewriteRule ^(.*)$ http://www.google.com [L] You can generate your own at http://ip2location.com/free/visitor-redirection .



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