Tag Info

Hot answers tagged

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


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

But the Official documentation clearly states it is used only for the RewriteRule directive. The docs don't say that it can only be used on the RewriteRule directive. The page you link to (which incidentally is specifically about the RewriteRule flags) simply states: Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive ...


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


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


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.



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