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

Try using the mod_expires syntax using something like this: <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access 2 week" ExpiresByType image/jpeg "access 2 week" ExpiresByType image/gif "access 2 week" ExpiresByType image/png "access 2 week" ExpiresByType text/css "access 2 week" ExpiresByType text/html "access 1 hour" ...


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

First off the easiest one for www is this. RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^yourwebsite\.com$ [NC] RewriteRule ^(.*)$ http://www.yourwebsite.com/$1 [R=301,L] Now for some actual rewriting you should be able to use something like this. RewriteCond $1 !^(users) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ...


1

From your comment I take it that you just created a plain text password. This will not work for Apache, as Apache expects the password in .htpasswd to be hashed by the MD5 algorithm. There are several tools available online for generating .htpasswd files, but the easiest might be the one that comes with Apache, it's called htpasswd. On RHEL (Fedora, Red ...


1

Make sure that you are including the entire path for AuthUserFile. I would suggest that you create a protected directory instead of doing this on the root directory. I made sure and tested these configurations to ensure that they worked. File Locations /protected/.htaccess /protected/.htpasswd .htaccess File AuthType Basic AuthName "restricted area" ...



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