New answers tagged htaccess
2
You can use the .htaccess file to redirect from IP to domain using this code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^555\.555\.555\.555
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Change 555.555.555.555 to match the IP of your server, additionally though you can use canonical urls that will prevent duplicates entering ...
1
This isn't really an answer to the question, but you may want to bear in mind that Google's guidelines says to avoid using URLs with parameter strings in, for languages or other wise.
So If your making the effort of tidying up your URLs you might as well follow best practices.
Google Guidlines URL structure
Google Guidlines Multilingual sites and URL ...
1
Something like this will work.
RewriteCond %{QUERY_STRING} ^(lang=es)$
RewriteRule ^$ /es/page.php?lang=es
RewriteRule ^index.php$ /es/page.php?lang=es
Since you can't match against a query string inside a rewrite rule we utilize %{QUERY_STRING}. If you use a relative path, as in the example, you will get a silent redirect (eg. the URL will not change, ...
0
If you want to do a 301 redirect you will have to use the full URI path including the FQDN and protocol. Like so:
RewriteRule ^(\S+)/directory/(\d+)/(\d+)/entry/(\d+)/?$ http://www.example.com/directories/index.cfm?sFuseAction=XXX.YYYY.ZZZZ&nDirectoryID=$2&nEntryID=$4&nCategoryID=$3&sDirectory=$1 [NC,L]
2
I know you previously asked to block the bots and now you just want to slow them down.
The only way to force them to slow down is not to serve them content if they are going too fast. The problem with not serving content is it will surely have negative consequences to your search engine rankings.
In case you decide to block some of the less important bots, ...
2
This should work for files of any extension:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^/(.*\..*)$
RewriteRule ^index\.php$ http://www.newsite.com/%1? [L,R=301]
Or to redirect the entire path and file request:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^/(.*)(\..*)$
RewriteRule ^index\.php$ http://www.newsite.com/%1%2? [L,R=301]
0
You could try using a simple Apache Redirect, like this:
Redirect 301 /index.php?/About.html http://www.newsite.com/about.html
It doesn't use regular expressions, so shouldn't care about the question mark and is simple to use. The only downside is that you'll need one per page - but if the structure and names aren't the same/similar on the new site, you ...
0
Ok, I finally got this to work (sort of). Here's my final code
RewriteCond %{REMOTE_ADDR} !=123.456.789.0
RewriteRule ^secretdir- [F]
I removed the escaping of the periods, and now it seems to work with my external IP address. I'm not sure if that's what is actually causing the problem, but now it works.
I say that it sort of works because (1) it's not ...
2
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Should do the trick.
0
This is mainly down to caching. Your pages may be served from a user's local browser cache, which will continue to log visits from old URLs. Other users may be viewing a cached version in Google, which also carries Google Analytics code.
1
I replicated your setup. There are two problems:
I can't get the %20 in the rewrite URL to work. I can get the rule to work if I replace %20 with +. A plus sign should URL decode to a space the same way a %20 does, so it should be treated the same in your matchevent.php script.
It was redirecting me to a bad relative path. If I change the redirect path ...
0
You should be able to add a rewrite condition to prevent WordPress from taking over the URLs for tracker: RewriteCond %{REQUEST_URI} !tracker/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !tracker/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond ...
0
There can be many reasons for this. But without seeing the htaccess file, we may not be able to give out any definitive answers. So I suggest you post your code here for us to review.
You may be redirecting your pages to a directory that does not even exist, and hence the 404 errors.
0
You need to add conditions to your match, like this:
RewriteCond %{REMOTE_ADDR} !=123\.123\.123\.123 [OR]
RewriteCond %{REMOTE_ADDR} !=123\.123\.123\.124
RedirectMatch 302 ^/mydir/.*$ http://mysite.org/myotherdir
Obviously, replace the 123 stuff with the actual IP addresses in question, remembering to escape the dots, as shown.
2
This is normal for dynamic pages. An ETag is a unique identifier for that version of a particular file. The web server can automatically set ETags for static files (html, css etc.), because it can work out when their contents were last changed by looking at the file's last modified time (and some other attributes). There's no way for the web server to know ...
1
When using relative paths Apache performs an internal rewrite (eg. index.htm becomes bob.htm). When using complete paths Apache performs an external redirect (eg. the url changes).
1
This isn't really a property of .htaccess files, but of Apache configuration directives in general - many directives being applied in a <Directory> or <Location> block will apply to child directories, and .htaccess files are essentially another way to configure <Directory> blocks.
If you had control over where the subdomains were in the ...
0
Your .htaccess looks like you are using Wordpress. Is this true? If that is the case, just go to Settings -> General and change WordPress Address (URL) and Site Address (URL) to versions with 'www'.
0
I would mix the two answers above
1. you HAVE to set properly the website URL So that the CMS always prints the correct address
2. you can set a proper rewrite rule so that in case someone links the wrong url [without www] you don't end up with google indexing all pages twice penalizing the SEO ranking
0
Altering the .htaccess shouldn't be necessary. You should only need to change the website URL under Settings -> General in the WP Admin to include the www.
If you try John's answer and you have the website URL in WP settings set to the non-www version, you will create a redirect loop.
WordPress 3.5
0
Looks like you are looking for file-extension based redirects:
RewriteRule ^/(.*\.(zip|jpg|png))$ /wp-content/uploads/$1 [L]
not sure of the correct syntax with folders, but in theory this should work...
0
how is actual rule for www.example.com/support ?
i would suggest to create a rule that only apply to that URL [and redirects to the very same page], add a [L] command flag and THEN insert the ^/support/(.*) statement
3
Very simple. Just create another .htaccess file in the /subsite directory, and set your ErrorDocument 404 in it to the subsite's 404 page, ie ErrorDocument 404 http://example.com/subfolder/alternate-404.html. The .htaccess in the parent folder will still be used for the main document root, and all other subfolders.
0
Using htaccess and php header redirect is best ways for your website, also better for Search engine optimization.
1
Assuming this is in the .htaccess in your document root, then you are almost there. You just seem to be missing the / (slash - directory separator) from the front of your destination URL (in the first example).
RewriteEngine On
RewriteRule ^somepage$ /abc/somepage.php [R=301,L]
The slash (or whatever is the base URL) is automatically removed from the ...
0
If you are wanting to get your images indexed for the appropriate keywords, that would often be included in the filename of the image, then referencing a php file without these keywords is not going to benefit SEO. Google doesn't only get keywords from the image filename, but it is a big clue, and it is helpful to users.
I can see that a RewriteRule ...
1
The htaccess does, by definition, slow down your site because the server must check every folder for the file - e.g. in your case the folders /patients/findadoctor/, /patients/ and the root folder. It is more efficient to write those rules in the server config itself, then set AllowOverride None, which will stop Apache looking for htaccess files. If you are ...
0
I ran into a similar situation yesterday. My website was working fin, but there were errors in Apache's error log. The problem was caused by a mistake in my PHP files, not in my RewriteRules.
My PHP files contained the following fragment:
<script src="javascript/package-min-1367246122.js"></script>
The missing slash caused "file does not ...
6
This is no doubt dependent on your remaining 200+ lines, but what you have posted so far would seem to be reducible to just 2 lines:
RewriteRule ^patients/billing/(FAQ_billing|getintouch).html$ $1.php [L,NC]
RewriteRule ^patients/findadoctor/([a-z]).html$ findadoctor.php?id=$1 [L,NC]
This shouldn't be reducing your site to a crawl.
As mentioned in ...
0
in your .htaccess file is it within
<Directory /path/to/the/directory >
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /home/u947248131/.htpasswd
AuthGroupFile /dev/null
require valid-user
</Directory>
More help http://httpd.apache.org/docs/2.2/howto/auth.html#gettingitworking
Otherwise if you can put the error log that ...
Top 50 recent answers are included



