.htaccess

Dependency Injection in PHP

I have been looking into Dependency Injection. Am I on to something or is it completely off? Is the code good or bad - Dependency Injection or not? The below code is the foundation for a CMS system Right now there is a table called "page_details" with all the web pages stored in it. Directory/file structure .htaccess index.php cla...

mod rewrite, trying to show a default image for ALL requests from a certain domain

This is what I have, but doesn't seem to be working. RewriteEngine on RewriteCond %{HTTP_REFERER} ^http://(www\.)?domain.com/ .*$ [NC] RewriteRule ^.*$ http://mydomain.com/new-pic.jpg [L] ...

.htaccess 301 redirect of single page

After a site redesign, I've got a couple of pages that need to be redirected. Everything is staying on the same domain, just a couple of things have been reorganised and/or renamed. They are of the form: /contact.php is now: /contact-us.php Using the .htaccess file, I've added this line, which is the one I find recommended most: Red...

I don't want to show the HTML file name as the home page, such as stackoverflow.com, instead of stackoverflow.com/home.

Using htaccess I was able to hide the file extensions, making it /home instead of /home.html. However, for the homepage, I would like to hide the file name altogether, for example stackoverflow.com, instead of stackoverflow.com/home. How do I achieve this? ...

Redirect pages from old to new site - one by one

Hi, I'm trying to redirect pages from several old domains on one new domain on a page-to-page basis, that is: page 1: http://www.example.org/default.asp?id=1 redirects to http://www.example2.org/newpage.html page 2: http://www.example2.org/default.asp?id=2 redirects to http://www.example.org/contact.html ...and so on. Every old page w...

Redirect to 404 if .php extension is requested

Hey, When a user requests a page that ends with .php, I want to send them a 404 error even if the page exist. Is that possible to do with .htaccess/mod_rewrite?? http://mysite.com/whatever.php ...

Good .htaccess/mod_rewrite/url-rewriting tutorial

Can you recommend me a very detailed URL rewriting/mod_rewrite tutorial that explains the whole process to the end, not just the basics? I have found numerous URL rewriting tutorials out there, each of them basic level. I understand why we use it, how we use it, what are regular expressions etc. What I am interested in is a very detail...

mod_rewrite help to change Content-disposition based on URI

I have a directory of mp3 files want to have be able to serve them inline or giving the user an option to download based on the request URI. /media/file1.mp3 -- in this case, I just want to serve the file and let the browser play it. /media/download/file1.mp3 -- in this case, I want to make it easy for a user to download the file inst...

Dealing with multiple, optional parameters with mod_rewrite

I'm using apache's mod_rewrite to make my application's URL's pretty. I have the basics of mod_rewrite down pat - several parts of my application use simple and predictable rewrites. However, I've written a blog function, which use several different parameters. http://www.somedomain.com/blog/ http://www.somedomain.com/blog/tag/ http://...

How to password protect an entire website but allow public access to 1 specific file

I've created an e-commerce site that uses paypal to accept payment. I am in the testing phase so I have password protected the entire site using htaccess. The trouble is that I am using IPN to verify PayPal payments and therefor my IPN script needs to be publicly accessible so that PayPal can communicate with it. Is there a way to pas...

How to remove .htaccess password protection from a subdirectory

I have password protected my entire website using .htaccess but I would like to expose one of the sub directories so that it can be viewed without a password. How can I disable htaccess password protection for a sub directory? Specifically what is the .htaccess syntax. Here is my .htaccess file that is placed in the root of my ftp Au...

.htaccess redirect/rewrite help needed

Hello, I am writing htacess redirect rule but it is not working properly I have tried many solutions but simply it is not working. What I want to do is to I have url http://example.com/cms/index.php?page=filename I want this url to be executed and show appropriate page but in browser it should show example.com/cms. And what is import...

.htaccess, YSlow, and "Use cookie-free domains"

One of YSlow's measurables is to use cookie-free domains to serve static files. "When the browser requests a static image and sends cookies with the request, the server ignores the cookies. These cookies are unnecessary network traffic. To workaround this problem, make sure that static components are requested with cook...

IIS: .htaccess php_flag / php_value alternative?

Hi all, For IIS (5.0 or higher), are there alternatives to apache's .htaccess directives php_flag and php_value to set PHP_INI_PERDIR config values? Thanks. ...

Improving this url with .htaccess and mod_rewrite

I have a URL I want to shorten with a mod_rewrite. In its ugliest form it looks like: /img.php?i=15&a=92 Ideally it would look like: /img/15/92 The problem is sometimes it might just be: /img.php?i=15 In which case the person will enter: /img/15 So I'm thinking I need a mod_rewrite like this: RewriteRule ^/img/(.*)/(.*)$ /i...

500 error when trying to add expires header to .htaccess

I'm trying to add a far future expires header by editing my .htaccess file this is recommended in the yslow performance rules but when I do, I get a 500 internal server error here's the code I'm using, any body know what's up? ExpiresActive On ExpiresDefault A0 ExpiresByType image/gif A2592000 ExpiresByType image/png A2592000 Expires...

.htaccess hide "last modified" and "parent directory"

Hi all, I'm trying to get my .htaccess file to list all files in the current directory, hide the 'last modified' column and also remove the link to "Parent Directory" all in the 'fancy' style. My current file is: Options +Indexes Any help would be great! Thanks ...

mod rewrite URL

hi i how can i change my site URL using mod_rewrite my problem is when i open my site's admin section i have to write www.example.com/index.php/admin what i want is i directly open my site like www.example.com/admin please help thanks ...

Getting destination and referer via .htaccess?

Hi! I want to write a .htaccess script that checks where a request is coming from and where it wants to end up. And depending on the result maybe do an action. For example, I want all scripts that are run from "/websites/{identifier}/" to pass a validation. If said script is trying to reach for a file or directory that is not in "/webs...

.htaccess and sessions for security?

Hi, In my application users have their own "websites" which can be reached if they are signed in. However, since these websites are just directories containing html and other documents everyone in the world can reach them if they know the address. I can't have that :) A user should be able to decide whether or not thw world might see t...