Tag Info

New answers tagged

0

Finally it worked by putting an additional line in the .htacces of the protected folder (call it private) ErrorDocument 403 /forbidden-because-of-protection and in the root's .htaccess I put the line like ErrorDocument 403 /forbidden-because-of-directory-listing So now when there is some request issued like /private/some/thing/bla the first .htaccess ...


2

You need to change your Redirect (mod_alias) to RewriteRule (mod_rewrite). Something like: RewriteRule ^word1/word2/word3 /word1/word2 [R=301,L] (Put back example/ if you wish, but it looked like a typo to me?) The problem you are experiencing is that mod_rewrite (nearly) always executes before mod_alias, regardless of the order of directives in your ...


1

A request for a directory listing will have a URL that ends in /. So http://example.com/images/ will be a 403 because of the directory listing. http://example.com/private/document.html will be a 403 because of your rule for the private directory.


1

I've solved it by using a script that redirects the user if he is logged into G+. I've scavenged the script from this site The explanation on how the script works can be found here.


1

Use 301 redirects and drop the file extensions. I can point you to some authoritative articles that will help you make your decision on how to approach redirects, URIs and SEO in general. 1) 301 redirects is considered the 'best-practice.' You can read the MOZ (widely considered and authority on SEO) article for more details. 2) As for best-practices on ...


0

I think that it all depends upon the inbound links to your site. I assume that they contain the .html and so I am working from this. If that is the case, then why upset the apple cart? I like your own suggestion: My first consideration was using an htaccess directive to process PHP files as HTML This seems like a good solution. I say this because link ...


0

Check wp-config.php to make certain it has all the right configuration settings in place, as well as any other information it may need, such as DB name, access and the like.


0

The .htaccess file is meant to be used by the HTTP Server, not PHP. Yet, you can setup PHP to read and adhere to the rules of the .htaccess file, if you need to do as such.


2

PHP doesn't work with the file over HTTP but directly on the filesystem, unless you access the file over HTTP using cUrl or file_get_contents('http://.../file.xml'). If you want to prevent the files from being accessed without the user being authenticated first, place the files outside the public directory and serve them from there. /files/ ...


1

Following on from comments... since you are wanting to completely remove these pages from Google's index then simply redirecting (301) them (as requested in your original question) is not necessarily the correct thing to do. Redirection is saying that the page has moved. Yes, Google is likely to drop the original page from the index... eventually, but that ...


2

I am going to assume you mean that any request for example.com/page.html outputs the content of the file from websitedirectory/page.html. If it was "redirected" then the browser would show the subfolder in the URL. In your case, there is no effect on SEO. Search engines will see the same URLs you see in your browser and won't know about the subdirectory ...


0

How about: RewriteRule (html|php)$ http://www.example.com [R=301,L] This matches all requests which end either with html or php strings.


-2

You can try these lines into a .htaccess file: RewriteRule ^(html|php) http://www.example.com [R=301,L]


0

In your case, instead of preventing indexing for your 404 pages, you should consider to create a specific 404 page by adding this line in your .htaccess file: ErrorDocument 404 /specific-404-page/ All your current 404 pages would be redirected to your specific 404 page and would be removed from search engines' index. If your current 404 pages are old ...


1

Maybe this link (how to redirect domain according to country IP address) can help you. I think, however, that this is not a good practice. Redirection by language or country is quite strict. It is better preferred: A message at the top of your site that influence the visitor to go to the page built with his language. A system that can easily change the ...


0

Google Webmasters also explains why the URLs are still indexed with their YouTube video. It takes a good while for the actual removal process of the old links to happen. Also, you have to remember, Google is indexing, re-indexing, and deleting records from their Search Engine all of the time at a massive rate already, but there is trillions upon trillions ...


1

I've had a quick test and this should do the trick: RewriteEngine on RewriteRule ^([0-9]+)/([0-9]+)$ /date/$1/$2 [R=301,L] You may also need to exclude this from the redirect to the index.php page by adding RewriteCond %{REQUEST_URI} !^/(date) [NC] so it should look like this # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On ...


1

The 403 Forbidden error is due to the access denied issue as intended, there is no issue here - that seems fine. The 404 Page Not Found error is due to your .htaccess file looking for and not finding where it expects, some kind of customised error page to show in this circumstance. It's possible your hosting provider may have this configured at the ...


3

It is likely that they have edited the .htaccess as root user and your FTP user will not have permissions to override root (no other user will) so unless you also have root access, you'll have to ask them to change the owner of the file to your FTP user so you can edit it.


1

Every time I read questions like this I think of Kevin Spacey's character in Henry and June. The fellow who was always writing his greatest Novel, but was so worried about someone stealing his ideas he kept it locked away in a briefcase, carried close to his chest... Every linux user is a "legit" wget user. I use it often for grabbing debs, videos, ...


5

wget has legitimate uses, yes, but it's also quite useful for Web scraping. However, I don't think you should try to block it (or any other agent) by using the user agent string. wget respects, by default, your robots.txt file. It's true that a scraper can just switch that option off, but guess what -- it's just as easy to use --user-agent ...


-1

Why another answer? Because both are right but with caveats. I study these things as a subject area regarding security. WGet is an offline web browser. It is not interactive like Linx which is a text based browser that works something like any other browser. WGet is most often used to capture resources such as downloads, videos, audio files and capture and ...


13

Wget is just a command line tool for linux that fetches resources over HTTP - all this tells you is that someone accessed your site via a command line, it could have been a bot scraping you, but there's no way of knowing for sure If your site is password protected properly, there shouldn't be any need to block particular user agents :) x


1

wget is often used for scraping. It's a command-line tool to download webpages and their assets. If your website isn't being publicized, you can almost be sure that it's a bot doing scraping. So yes, you could block it, but also be aware you may need to do something more sophisticated than blocking it with robots.txt since wget can easily be told to ignore ...


1

The best .htaccess code which I am able to give you to do the redirection is as following: # This allows you to redirect your entire website Redirect 301 / http://example.com/ You will have to modify the example as you add it into your .htaccess file.


2

RewriteRule ^.*$ index.php?page=$1 [NC,L] This will result in a rewrite loop. You are also not capturing the sub pattern, so $1 will be empty. In order to prevent a rewrite loop, you need a get-out-clause, such as not rewriting when the request is already for index.php. Something like: RewriteEngine On RewriteCond %{REQUEST_URI} !=/index.php RewriteRule ...


0

Your "Method 2" looks appropriate to me to match http://www.testdomain.com/john/2/doe. Only, you may want to try to add the RewriteBase / too, something like this: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+)/(.*)$ test.php?name=$1&id=$2&nick=$3 [L,QSA] Instead ...


0

I had a similar rule, try this one: RewriteEngine On RewriteBase / RewriteRule ^test/([A-Za-z0-9-]+)/([0-9]+)/([A-Za-z0-9-]+)/?$ test.php?name=$1&id=$2&nick=$3 Your links should be: test.php?name=john&id=2&nick=doe


3

You mentioned that two options are valid for you, so I'm using the second one, http://www.testdomain.com/john/2/doe, and assuming a clean .htaccess RewriteEngine On # RewriteCond %{REQUEST_FILENAME} !-f # RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{QUERY_STRING} ^name=([\w]+)\&id=([\d]{1,3})\&nick=([\w]+)$ RewriteRule .* /%1/%2/%3? [R=301,L] ...


2

You could set up theirsite.com as a parked domain on top of myscript.com. This initially allows theirsite.com to be an alias for myscript.com. You can then use mod_rewrite (in .htaccess) to internally rewrite to the real URL (similar to what you have done already). You can only rewrite to a URL on theirsite.com (not myscript.com), which shouldn't be a ...


2

Finally resolved using these rewrite rules: RewriteEngine on RewriteCond %{HTTP_HOST} ^www.unwanteddomain.com$ [NC] RewriteRule .* http://whateverPlaceYouWantToSend.com [R,L] HTTP_REFERER did not work so I used HTTP_HOST.


1

The way I would do this is block all requests which are coming from unwantedcomain.com by checking for HTTP_REFERER Block traffic from a single domain: RewriteEngine on RewriteCond %{HTTP_REFERER} unwateddomain\.com [NC] RewriteRule .* - [F] Block traffic from multiple domains: RewriteEngine on RewriteCond %{HTTP_REFERER} unwanteddomain\.com [NC,OR] ...


0

You define a rule backwards, so this is not working. The syntax is as following: This would work, but will most likely break your magento (as all urls with a dash "-" in it will be rewritten): RewriteRule ^/(.*)-(.*)$ /parent-category/sub-category/$2/$1 [L,NC] So I would suggest putting it under some kind of static keyword, like "shop", so when you ...


0

The PHP code that John Conde posted does not work. It replaces the entire .htaccess file as an undesirable result. The PHP below would be a good replacement for his PHP and I have tested it. <?php $ipdeny = 'deny from ' . $_SERVER['REMOTE_ADDR']; file_put_contents('.htaccess', $ipdeny . PHP_EOL, FILE_APPEND); ?>


0

I would use cookie for this on *.domain.com. Special cookie value (let's say lang) should only be set if user clicks on any of the flags. Now on www.domain.com when routing users to localized websites you first check if cookie with lang value is set, if so, you redirect to a page with lang specified in the cookie. If, however, such cookie would not exist, ...



Top 50 recent answers are included