mod-rewrite

Permissions set to 777 and file still not writeable

穿精又带淫゛_ 提交于 2019-12-21 17:21:45
问题 I have set file permissions to 777 yet I cannot write to the file with PHP. I can clearly see in my FTP client that the file has 0777 permissions and when I do: echo (true === is_writable('file.txt')) ? 'yes' : 'no'; I get 'no'; I also tried: echo (true === chmod('file.txt', 0777)) ? 'yes' : 'no'; With the same result. The directory listing goes something like this: public_html public 0777 css 0755 js 0755 file.txt 0777 And I'm using .htaccess file to redirect all traffic to the public

Simulating a 2-level If-Else using RewriteCond

走远了吗. 提交于 2019-12-21 17:06:22
问题 I'm trying to get my head around RewriteCond, and want to rewrite any requests either to a static html page (if it exists), or to a specific index.php (so long as the requested file doesn't exist). To illustrate the logic: if HTTP_HOST is '(www\.)?mydomain.com' if file exists: "/default/static/{REQUEST_URI}.html", then rewrite .* to /default/static/{REQUEST_URI}.html else if file exists: {REQUEST_FILENAME}, then do not rewrite else rewrite .* to /default/index.php I don't seem to have much

Changing Cookie Domains

牧云@^-^@ 提交于 2019-12-21 17:04:09
问题 I use apache as a proxy to my application web server and would like to on the fly, change the domain name associated with a sessionid cookie. The cookie has a .company.com domain associated with it, and I would like using apache mod rewrite (or some similar module), transparently change the domain to app.company.com. Is this possible ? and if so, how would one go about it ? 回答1: You can only change the domain of a cookie on the client, or when it's being set on the server . Once a cookie has

Are clean URLs a backend or a frontend thing

若如初见. 提交于 2019-12-21 13:13:17
问题 What do you think.. are clean URLs a backend or frontend 'discipline' 回答1: If we're talking url's being 'clean' from an end user experience then I'm going to break the mould a bit and say that url's in general are not intuitive and they never will be, they are intended to be machine readable. There is no standard to the format of a url such that when navigating from site to site humans will never ever remember how to reach a resource purely through remembering urls and their 'friendly syntax'

How to disable 301 redirect that adds trailing slash to directory name in Apache

雨燕双飞 提交于 2019-12-21 07:59:11
问题 The Apache 2.2.20 automaticaly redirects all requests which are points to directories and has no trailing slash to the same URL with trailing slash, like shown below: GET /some/path/to/dir HTTP/1.1 Host: www.some.org ... 301 Moved permanently Location: http://www.some.org/some/path/to/dir/ In all cases it is a fine behavior, but I need to turn off this feature for one special folder (not for all), and can't find were I can do it. Searching for 'Rewrite' rules tells founds nothing - only

.htaccess for subfolder of AngularJS app with HTML5 mode

那年仲夏 提交于 2019-12-21 07:57:28
问题 Overview : I have an AngularJS application that uses $locationProvider.html5Mode(true) and it is served from an Apache server. Until now I used the source code to be accessed from the others and I just needed a redirect to index.html for the angularJS's HTML5 mode. So I had this for the .htaccess file for my /app folder. .htaccess : <IfModule mod_rewrite.c> RewriteEngine on # Don't rewrite files or directories RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d

Rewrite all virtual subdomains to same folder using htaccess

假装没事ソ 提交于 2019-12-21 06:05:25
问题 I have been searching the internet trying to find a solution to this problem but cannot find a definite solution. I am trying to redirect rewrite anything.domain.com/anypage.php?sub=anything&including=get_parameters to domain.com/users/anypage.php?sub=anything&including=get_parameters I have found several pages with possible solutions but they all differ slightly to my needs, and editing them continually ends in failure. Any help would be much appreciated. Thank you. P.S Wildcard DNS are

htaccess: force http on all pages and https on select directories

馋奶兔 提交于 2019-12-21 05:43:26
问题 I have the following: RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} protected [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301] RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI} !protected [NC] RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L,R=301] If the directory is called "protected", make sure that the user is using https. If the directory is anything except "protected", make sure the user is using http. This works great, but how do I specify additional directories? Also, is

.htaccess not working in amazon ec2 ubuntu instance

感情迁移 提交于 2019-12-21 05:11:15
问题 I have a server from amazon's ec2 service running on Linux Ubuntu ( Ubuntu Server 13.04 64 bit) and I have installed apache, php, and mysql. I have added a .htaccess file in my document root (i.e /var/www/). Here is the code in .htaccess file as follows: RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php If I remove .php from url like "index1" instead of "index1.php", it returns 404 browser error. It works

What Double Colon does in RewriteCond?

牧云@^-^@ 提交于 2019-12-21 05:10:06
问题 Example: RewriteCond %{REQUEST_URI}::$1 ^(.*?)/?(.*)::\2$ Looks like this operator is nowhere to find in any reference or manual. Where can I find it or anyone could explain what this operator does? 回答1: Rules like this: RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$ RewriteRule ^(.*)$ - [E=BASE:%1] can also be written as (using ## as fixed delimiter on either side of condition): RewriteCond %{REQUEST_URI}##$1 ^(.*?/)(.*)##\2$ RewriteRule ^(.*)$ - [E=BASE:%1] Explanation: You could use $1