Tag Info

New answers tagged

2

I personnaly use this: RewriteEngine on RewriteCond %{HTTP_HOST} !\..+\. RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L] It checks if there is NOT 2 dots in the domain name. This is very similar to what w3d proposed, I just find it more readable. And as w3d stated, it is impossible to have a fully generic solution because nothing allow to guess how ...


3

I don't think you can make it completely generic, since you'll need to make exceptions for your subdomains, unless there is a pattern to your subdomains? A workaround is to add each subdomains to the regular expression. Well, yes unfortunately... RewriteEngine on RewriteCond %{HTTP_HOST} !^(wiki|sub2|sub3)\. RewriteCond %{HTTP_HOST} ^(?!www\.)(.+) ...


2

redirect 301 http://m.somesite.com/site/somesite/faqs http://www.somesite.com/faqs/ This doesn't work because the source URL needs to be a URL-path, starting with a slash (as you have used for the redirects that work), not an absolute URL. In other words, it should be written as the following (in a .htaccess file located at the subdomains document ...


0

Your logic appears to be reversed... you need to remove the OR flag at the end of the first RewriteCond directive. This looks like it should be an implicit AND: RewriteCond %{HTTP_USER_AGENT} !Version/[1-5] RewriteCond %{HTTP_USER_AGENT} !MSIE\ ([6-8]) In other words... if it's not Safari and it's not IE6-8 then proceed... If you OR these two conditions ...


2

You want to do a blanket redirect from one domain to another. Assuming Apache, put in your .htaccess file in the root directory of example0.com: RewriteEngine on RewriteRule ^(.*)$ http://www.example1.com/$1 [L,R=301] This will redirect all requests from 0 to 1 and keep the original request URI.


3

If you're getting alot of requests with undefined added to the URLs and you know the things accessing those URLs are people and not robots, you're much better off using HTTP status code 301 and redirecting the URL to the correct one. Using status code 204 will not help because it means "No content" and the user will then need to manually modify the URL in ...


3

In order to match "undefined" at the end of the URL-path you need the regex pattern undefined$. The pattern ^undefined$ (which you've used in your question) matches the exact URL "undefined", which is never going to match, unless the request is for http://example.com/undefined. This directive should go at the top of your .htaccess file (after the ...



Top 50 recent answers are included