.htaccess

Restrict access to directories through ip address

狂风中的少年 提交于 2020-03-26 07:06:57
问题 I have a webserver with apache, say ip is 12.345.678.90 . In my www directory there are a few sites, say, site1 and site2 . Both belong to the same ip address - I created virtual hosts. Websites are on cakephp framework and there are a lots of directories, for example, app , app/tmp , lib , lib/Cake etc. When accessing the website like http://site1.com or http://site2.com everything is all right, and no way these directories can be viewed or accessed, but through ip I can see everything. http

.htaccess <filesMatch> only if host name matches?

戏子无情 提交于 2020-03-24 08:03:07
问题 I just setted up a local environament with same code that I had in production environament into a vagrant virtual machine with ubuntu32, The thing is that I got Internal Server Error with all my rules in the .htaccess file So I started removing separated blocks of code and this was the trouble: # 1 weeks <FilesMatch "\.(js|css)$"> Header set Cache-Control "max-age=604800, public" </FilesMatch> # 1 weeks <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age

htaccess rewrite rules to remove multiple subfolders from a URL

半腔热情 提交于 2020-03-23 02:07:27
问题 Due file system sub-directory constraints I will most likely reach I want to separate the /users folder into /users/a/username , /users/b/username , /users/c/username , etc. So the data on the server for a user would be in: www.domain.com/users/a/username/ , www.domain.com/users/b/username /, etc I want the URL to be: www.domain.com/users/username/ Optionally to avoid duplicate content a 301 redirect from www.domain.com/users/a/username/ to www.domain.com/users/username/ would also be good.

htaccess rewrite rules to remove multiple subfolders from a URL

▼魔方 西西 提交于 2020-03-23 02:07:22
问题 Due file system sub-directory constraints I will most likely reach I want to separate the /users folder into /users/a/username , /users/b/username , /users/c/username , etc. So the data on the server for a user would be in: www.domain.com/users/a/username/ , www.domain.com/users/b/username /, etc I want the URL to be: www.domain.com/users/username/ Optionally to avoid duplicate content a 301 redirect from www.domain.com/users/a/username/ to www.domain.com/users/username/ would also be good.

Rewrite to append to query string

若如初见. 提交于 2020-03-21 19:54:07
问题 I don't understand why I always have such a massive problem with rewrite rules, but I simply want to append to the query string if it exists and add a ? if it does not. I actually don't care if the URL is changed in the browser or not -- it just has to load the correct target page. RewriteRule /cia16(.*)\?(.*) /cia$1?$2&CIA=16 RewriteRule /cia16(.*) /cia/$1?CIA=16 If I go to /cia16/steps.php?page=1 it actually gets rewritten to /cia/steps.php?CIA=16 -- that is it seems accept the query string

How to block direct download file

喜欢而已 提交于 2020-03-21 03:31:22
问题 My website contains some download content. I want to access download this file only for logged in user. If user type direct file url in browser it show forbidden page if user not logged in. Am not using any CMS. Direct File Link: localhost/files/questions/20160917070900-w2CdE9LZpE.zip I searched on net but failed to find any good answer. Please suggest me how can I do it. 回答1: Into folder members create new folder files, move here all your songs, create new .htaccess file and add the

How to block direct download file

妖精的绣舞 提交于 2020-03-21 03:27:25
问题 My website contains some download content. I want to access download this file only for logged in user. If user type direct file url in browser it show forbidden page if user not logged in. Am not using any CMS. Direct File Link: localhost/files/questions/20160917070900-w2CdE9LZpE.zip I searched on net but failed to find any good answer. Please suggest me how can I do it. 回答1: Into folder members create new folder files, move here all your songs, create new .htaccess file and add the

Explain htaccess rules?

情到浓时终转凉″ 提交于 2020-03-19 05:29:12
问题 I have made this .htaccess file over the last hour through searching, copy and pasting etc. It does work how I want it to. However I do not understand it. Could someone please put it down step by step what is happening here in layman's terms for me. RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^/?(.*)$ /$1.php [L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php RewriteRule ^/?(.*

Explain htaccess rules?

泪湿孤枕 提交于 2020-03-19 05:29:08
问题 I have made this .htaccess file over the last hour through searching, copy and pasting etc. It does work how I want it to. However I do not understand it. Could someone please put it down step by step what is happening here in layman's terms for me. RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^/?(.*)$ /$1.php [L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php RewriteRule ^/?(.*

mod_rewrite with name replacing ID

ε祈祈猫儿з 提交于 2020-03-05 09:46:34
问题 I have a page on my website that dynamically displays content. The URL structure is mywebsite.com/giveaway/giveaway.php?id=(any number) I wish to change that dynamic URL into a static/friendly URL mywebsite.com/giveaway/name-of-giveaway-corresponding-to-id . In my .htaccess file found in my root folder i have the following: RewriteEngine On # external redirect from actual URL to pretty one RewriteCond %{THE_REQUEST} \s/+\?page=([^\s&]+) [NC] RewriteRule ^ /page/%1? [R=301,L] # existing rule