.htaccess

Mod Rewrite: apply to all js and css files except ...

Hi I need to apply a minify actions to all the javascript and CSS files, except the ones I indicate. I have this condition and rule that applies to all the files (css and js): RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*\.)(js|css)$ minify.php?q=$1$2 [L,NC] I need to add the conditions to say: Apply to all except: jquery.js,...

Is PHP allowed to modify .htaccess file in current folder?

I have a PHP web app located on shared hosting. My goal is to modify .htaccess file from PHP code when the PHP page is running. I need that .htaccess to insert a couple of mod_rewrite lines into it. The problem is that on Windows+Apache I can dinamically modify .htaccess file but the same code on Linux reports a problem when I try to ac...

Force https for entire server/domain

I am developing a number of forms which should only be accessed via https. I have a dedicated server with its own cert and all the good stuff. So my question is two-fold really: 1). What's the best way to force every request to be https? Is there a better way than this .htacess/mod_rewrite rule: RewriteCond %{HTTPS} off RewriteRule (....

RewriteRule - a.php?a=123 to /b/123

I am trying to get Apache to redirect /a.php?a=123 to /b/123 (where 123 could be any number between 1 and 9999) but can't seem to get it to work. This is what I have in htaccess: RewriteEngine on RewriteRule ^a.php?a=([0-9]+) /b/$1 [L] RewriteRule ^a.php$ /c/ [L] With this going to a.php?a=123 results in 404, but going to just a.php...

Forcing SSL & www subdomain for any URI entered with .htaccess?

I have an SSL certificate for the 'www' subdomain of a web site we'll call example.com. Therefore I can force SSL, but if the user doesn't enter 'www.example.com' into their browser, the SSL certificate appears invalid. I wish to accomplish this with mod_rewrite rules in an .htaccess file at the root of the web site. No matter what UR...

how to write this in htaccess

I am using godaddy and what I want to do is when someone types in a domain address I want it to automatically redirect to a folder rather than placing the files on the root so its more organised. How do I write this in .htaccess? ...

editing .htaccess file

I'm made a codeigniter app and I tried to use the apache mod_rewrite rules as RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] The problem is that I have this app in a folder abc/ but when I type mysite/abc/something (which should point to mysite/abc/index.php/somethin...

Apache RequestHeader Directive in .htaccess

Hello I am trying to use the following apache configuration on a Godaddy shared hosting account: <Files ~ ".*"> <IfModule mod_headers.c> RequestHeader unset Host RequestHeader append Host mydomain.com </IfModule> </Files> The above is contained in a .htaccess file. In other words... For all files and paths set the request's host to m...

Create Subdomains on the fly with .htaccess (PHP)

I am looking to create a system which on signup will create a subdomain on my website for the users account area. e.g. johndoe.website.com I think it would be something to do with the .htaccess file and possibly redirecting to another location on the website? I don't actually know. But any information to start me off would be greatly ...

How to force apache requests to use CGI WITHOUT the use of .htaccess

My school internal webserver is still running PHP v4.. (Not sure exactly). I went ahead and wrote all the labs and assignments on my local machine, which is running 5.2.5. Now, none of my code works on the school machine because the functionality simply is not there. I have access to a slew of compilers, and have downloaded the PHP v5...

IP restriction with htaccess

Hi guys! I want to restrict an entire site in such a way that just two IPs could enter the site. I have the following in my .htaccess (at the root of site): ErrorDocument 403 http://www.example.com/views/error403.html Order Deny,Allow Deny from all Allow from 311.311.311 322.322.322.322 ErrorDocument 404 /views/error404.html ErrorDoc...

.htaccess file opinion (howto)

I like to make a .htaccess file to redirect any errors I get from a web site. I have deleted all pages from the old site. But I have no idea what pages people have bookmaked. The new webpage and website structure is totally different ... so no page is the same as the old one, not event the index document that changed from index.html to...

How can I turn all rewrite x.php into x.css in a specific directory?

I need to rewrite all the files in a directory and essentially make their extentions css instead of php. I want to do with with a .htaccess file within that specific directory. What is the correct method of doing so and are there any special PHP headers I need to set the ensure the file is read as a .css file correctly? ...

Redirect requests only if the file is not found?

I'm hoping there is a way to do this with mod_rewrite and Apache, but maybe there is another way to consider too. On my site, I have directories set up for re-skinned versions of the site for clients. If the web root is /home/blah/www, a client directory would be /home/blah/www/clients/abc. When you access the client directory via a w...

Why modRewrite applies automatic .php to this simple rule?

Ok guys i have maybe a stupid problem, but i'm probably dumb :) I have this simple .htaccess: Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^news/([^/]+)$ news-inside.php?n=$1 [L] RewriteRule ^news/?$ news.php [L] RewriteCond %{REQUEST_FILENAME} !-f Every time i try to get into firs...

Rewriteengine in .htaccess to catch files not ending in html

I'd like to use mod rewrite in to convert web page addresses like /directory to /directory/index.html, in a standard LAMP hosting situation. What I have works for addresses that end in a slash. I can't find a way to handle addresses that don't end a slash. What seems like it should work is: rewriterule ^(.*)/$ $1/index.html [L] /* addr...

Is storing config variables in an XML file on a PHP site under the site root too risky?

I've noticed that Magento stores MySQL connection details in an XML file which isn't secured above the docroot. This seems.... well dangerous. XML seems like a handy way to store config data, except for one thing, typing in http://www.domain.com.au/library/config.xml will show the world your private details! I went ahead and used an XM...

Why can't I disable .htaccess in Apache?

This is the opposite problem from most about which I have read. I am running Ubuntu 8.04 on an Amazon instance with Apache 2.2.8 and I can't figure out why setting AllowOverride to None for root doesn't stop my .htaccess file from being included. I have a sub-directory with hello.py in it and an .htaccess file. When I browse to the file...

What do these declarations mean in my .htaccess file?

I am a newb to PHP. Can anyone tell me what each line does here. Do I need this? It is giving me errors RewriteCond %{REQUEST_URI} /~([^/]+)/? RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*) /~%1/rewrite.php?p=$1&%{QUERY_STRING} [L] RewriteCond %{REQUEST_URI} /~([^/]+)/? RewriteRule ^index\.p...

Setting a Php $_SERVER value ($_SERVER['something']) using Apache .htaccess

Is it possible using .htaccess or other apache powers to set a custom server value in the php array $_SERVER. for example if($_SERVER['is_special']) { echo "Yeah for us!"; } else { echo "No you fool!"; } I realize I ask a lot of questions that the answer is no so feel free to say so. ...