.htaccess

Secure PHP file uploading

I'm trying to develop a file uploading module on our new site that allows you to upload any file to our servers. The uploaded file is uploaded to /files, in which the following .htaccess to prevent users from executing i.e a .php file: <Files *.*> ForceType applicaton/octet-stream </Files> This triggers the browsers download window (a...

.htaccess redirect if file doesn't exist

So here's what I'm trying to do. I have a simple framework and I am using mod rewrite to rewrite the urls so that they point to the correct files. I have a process folder which sits inside the web folder (the web folder is where all the actual website files like images, css, etc are). This works great but what I am trying to do now is t...

Using .htaccess to redirect from one domain to another

Hi, I recently purchased a new domain for my WordPress site and I want to redirect anyone who visits using an old domain to the new one. I haven't moved servers, just added a new domain. For instance, if they went to either of these: http://www.example.net/some-article/ http://example.net/some-article/ Then I'd like them to be redir...

Manage url-writing in .htaccess or in PHP code?

I'm studying how to do url rewriting in a LAMP framework. I began my research by studying wordpress code. I looked at wordpress's .htaccess and saw this: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfMod...

Popular techniques to debug .htaccess

I'm a self-taught coder and I like to debug by echoing suspicious variables and commenting out code. Lately, I've had to learn more about the .htaccess file. I need it to do things like interpret php scripts as php5, url rewriting, limit file upload size etc.... I have a lot of trouble debugging a .htaccess file. I often have to mi...

RewriteLog triggers Internal Server Error

I am trying to do some debuging on my rewrite rules and wanted to enable RewriteLog to view how they are interpreted. but when i activate it i get Internal Server Error heres the line: RewriteLog "/home/solomongaby/www/project/logs/rewrite.log" thanks ...

How do I use .htaccess to force www. while using Zend Framework

I want to force a www. prefix on my website by using a .htaccess 301 redirect. I am currently trying: RewriteCond %{HTTP_HOST} ^mysite.com [NC] RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301] Which normally works, but I am using Zend Framework which causes all requests to be redirected back to http://www.mysite.com/index.php reg...

.htaccess not working in Chrome/IE/Opera?

I have an .htaccess file that is redirecting everyone to the www. version of a site. Like so: RewriteCond %{HTTP_HOST} ^baldwinbrothersinc\.com$ [NC] RewriteRule ^(.*)$ http://www.baldwinbrothersinc.com/$1 [L,R=301] When I go to baldwinbrothersinc.com in Firefox or Safari, I am redirected to www.baldwinbrothersinc.com . ...

Unable to show siteA's content at siteB by domain masking

I have a domain www.siteA.com, which uses Joomla, while the domain www.siteB.com is empty. I would like to show the content of the domain www.siteA.com at www.siteB.com. I tried to solve the problem first by making a domain redirection by .htaccess, but I could not show SiteA's content at SiteB. How can you show the contents of mysite...

stop subdomain access root

i have root and subdomain (for my friend) like this /home/blahblah/ /home/blahblah/domain.com/ (Apache server) can i stop subdomain access root by using some php shell script? ...

URL Rewriting - Redirect With No File Extension

I am currently using the following rules in an htaccess file: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php This works well to ensure that myfile.php works as well as just myfile (with no extension). It also handles querystring's with no problems, so myfile?var=f...

How many RewriteRules can you have in .htaccess without trouble?

Simple question. Is there a limit as to how many RewriteRules I can have in my .htaccess or can I put a zillion of them in there without Apache going all funky on me? Is there a relative limit where the server simply dives because there are to many rules to iterate through? Thanks! ...

htaccess redirect

This is what I'm trying to do with the htaccess: Force remove the www from the url Be able to use http://website.com/site/ to get to http://website.com/site.php, and force the last slash even if it's not added by the user. So if i write http://website.com/site it will be converted to http://website.com/site/ Also translate http://websi...

htaccess conditional rewriterule problem

My rewriterule with a condition is working fine as below: http://www.sitename.com/index.php?n=text redirects to http://www.sitename.com/pages/text and the page renders properly, however, there is a problem that with the redirected URL the arguments are also added to the URL. So actually in address bar it looks like- http://www.sitena...

.htaccess !-f rule not working

I have been using simple mod_rewrite rules for my CMS for years and am now making a new version, I am seeing the rewriteCond not making sense- I have the standard "if is not a file" but I still see the rewriterules being evaluated even though they're not supposed to. My rewrite code: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQ...

Translating an Apache .htaccess file to an IIS web.config

Hello there, I developed an application on my local using PHP, MySQL and Apache and it has a .htaccess file containing this: #Setting the default handler. DirectoryIndex home.do <IfModule mod_mime.c> #Supporting .do extensions AddType application/x-httpd-php .do </IfModule> <IfModule mod_rewrite.c> #Removing .do file ex...

.htaccess in Notepad ++

I am working with Notepad and the FTP plugin. The .htaccess files do not show up in the folder tree of the server. Anyone else encountered this and know of a fix? ...

How does RewriteBase work in .htaccess

I have seen this in a few .htaccess examples RewriteBase / It appears to be somewhat similiar in functionality to the <base href=""> of HTML. I believe it will automaticlally prepend it's value to the begining of RewriteRule statements (possibly ones without a leading slash)? I could not get it to work properly. I think it's use co...

Why would this .htaccess skip over my RewriteBase ?

Here is the begining of my .htaccess # invoke rewrite engine RewriteEngine On RewriteBase /~new # force non domain.com to www.domain.com RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301,L,NC] everytime I request http://www.example.com/~new/whatever I am sent to htt...

PHP error in .xml file?

OK firstly, I added this line to my .htaccess file so the php engine parses php code in .xml file: AddType application/x-httpd-php .php .php3 .phtml .html .xml After that when I view an .xml file I get this PHP error: Parse error: parse error, unexpected T_STRING in /var/www/vhosts/mydomain.com/httpdocs/test.xml on line 1 But line 1...