.htaccess

htaccess block domains from hotlinking images

允我心安 提交于 2019-12-31 04:46:12
问题 I blocked some sites in the file but they keep comming on my server and asking for images that slow down my server how i can add a rule for them so they will see big red sign STOP HOTLINKING RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} ^http://(www\.)?somesite\.pl [NC,OR] RewriteCond %{HTTP_REFERER} ^http://(www\.)?somesite\.pl [NC,OR] RewriteCond %{HTTP_REFERER} ^http://(www\.)?somesite\.pl [NC,OR] RewriteCond %{HTTP_REFERER} ^http://(www\.)?sklep.somesite\.eu

Using htaccess to redirect a directory, but not the files in it

那年仲夏 提交于 2019-12-31 04:41:08
问题 On my website, I've got a directory /folder with some images and html in it. I want to redirect users who try to access http://domain.com/folder to http://domain.com/ but don't want requests for the files in that directory to redirect to http://domain.com/ either. When I try Redirect /folder http://domain.com/ it breaks the site because now it thinks all the images, etc are in the root directory when it is not. How do i fix this? 回答1: Use RedirectMatch instead: RedirectMatch ^/folder$ http:/

Rewrite URL with .htaccess

爱⌒轻易说出口 提交于 2019-12-31 04:39:24
问题 I've this url: http://www.test.com/page.php?k=m1ns and I want this one: http://www.test.com/r/m1ns My .htaccess: Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^k/([^/\.]+)/?$ page.php?k=$1 [L] # force www. in all requests RewriteCond %{HTTP_HOST} ^test\.com [NC] RewriteRule ^(.*)$ http://www.test.com/$1 [L,R=301] # enable hiding php extension RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php But it doesn't work. Only the

Unable to hide htaccess file

核能气质少年 提交于 2019-12-31 04:27:08
问题 I'm having a difficult time hiding my .htaccess file -- I double-checked to ensure the following was present in httpd.conf: <Files ~ "^\.ht"> Order allow,deny Deny from all </Files> Other allow/deny directives on directories are working and the directives in the visible .htaccess file are working. We are running Red Hat Enterprise Linux Server release 6.3 (Santiago) and Apache/2.2.15. My question: Aside from the obvious of, "Why is the .htaccess file still visible?" Is there some other

What is the difference in operation between . and ^ and ^(.*)$?

梦想的初衷 提交于 2019-12-31 04:25:14
问题 What is the difference in operation between: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [L] and RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] and RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L] I know that "." means any character and "^" beginning of string. Thanks for reply! 回答1: First let's understand how landing page is matched.

URL Rewriting for user profiles

大城市里の小女人 提交于 2019-12-31 04:24:10
问题 I am using a hash value to prevent spam and direct access to user profiles with changing ID numbers. This is a unique integer value given user once when they registered, stored in database and never change. Profile links look like this: example.com/profile.php?id=xxx&hash=xyz I want to rewrite URL with user nicknames, like this: example.com/nickname But how can I do it when using a hash value in URL? I couldn't find a sample for this! 回答1: If I understand you well: You want to provide to the

Mod_rewriting a query string onto a swf file

强颜欢笑 提交于 2019-12-31 04:18:08
问题 I'm attempting to use mod_rewrite to clean up the URL's to a flash video player. First, here is the original URL that I'm trying to rewrite to: library/player.swf?path=path-to-file.flv The above URL works perfectly fine when I access it directly. I have coded the swf to automatically grab the path parameter and play the video. No problems there. Now here is my attempted rewrite rule: RewriteRule ^player/(.+)$ library/player.swf?path=$1 [QSA,L] When visiting the url player/path-to-file.flv, I

.htaccess redirect to “https://www”

南楼画角 提交于 2019-12-31 04:08:14
问题 I'm looking for an .htaccess configuration that will redirect all requests to my site to https://www . So whether the user visits: www.example.com http://example.com http://www.example.com https://example.com They will always end up at: https://www.example.com Here is what I am currently using in my .htaccess file, however it doesn't redirect if a user visits: www.example.com Here is my current file contents: RewriteEngine on RewriteCond %{HTTP_HOST} ^example\.com [NC] RewriteRule (.*) https:

.htaccess , How to redirect any .jpg page to its attachment page (HTML)

…衆ロ難τιáo~ 提交于 2019-12-31 04:05:06
问题 I want to redirect www.domain.com/images/Apple.jpg to www.domain.com/Apple.html Here is the Live working example, This is what i exactly want http://more-sky.com/data/out/2/IMG_21306.jpg How it redirect to its parent page i.e (http://more-sky.com/WDF-21306.html) 回答1: Assuming you have mod_rewrite enabled in your Apache: RewriteEngine On RewriteBase / RewriteRule ^images/([^\.]+)\.(jpe?g|png) /$1.html [QSA,L] Edit: as noticed by Wh1T3h4Ck5, QSA ( Query String Append ) flag would be optional,

How to convert text to lowercase URLs using .htaccess

北战南征 提交于 2019-12-31 04:04:06
问题 I want to set up 301 redirects in my .htaccess file so URLs like http://example.com/Foo http://example.com/Foo/Bar http://example.com/Foo/Bar/Blah change to http://example.com/products/foo http://example.com/products/foo/bar http://example.com/products/foo/bar/blah There are a discrete number of "Foo" cases which I can target with RewriteRule ^Foo, but how to append the "products" part? 回答1: First add this line in <VirtualHost> section OR at the end of your httpd.conf file: RewriteMap lc int