Removing index.php from Magento URL’s

This should be the default behaviour, if you ask me, however no one asked me.

Log in to the admin panel, and navigate:

System > Configuration > Web > Search Engine Optimization

Use web server rewrites is the option we’re looking for. Lastly, create an .htaccess file, with the following in it:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Users of ZF should be quite familiar with an .htaccess like this. That’s it, job done!

Installing a ZendFramework App on IIS

Yes yes I know. Please. I’m just doing my job.

Anyway, hatred of MS and their less than satisfactory web based products aside, heres how to set up a Zend Framework App on IIS. I am assuming IIS is already up and running and that PHP is installed (only because thats where I started from)

Open IIS, in the computer click on Web Sites.
In the action menu click new website.
Put in a description, hit next.
Stick the servers IP in, port, and domain, hit next
Browse to sites home path hit next
Assign permissions (I had to browse to folder, right click and un-read-only my session, uploads, and logs folders), hit next, and finish.

Ok. Now IIS uses some thing thats similar to .htaccess, only it isn’t. Its called IIRF, and it needs setting up if it isn’t already. You can get it here: Download the Ionic’s ISAP Rewrite Filter (IIRF) here

Create Iirf.ini and shove this in it: (this took hours of farting around to get working :-s )

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^/(.*(\.js|\.swf)(\?.+))$ - [L,I]
RewriteRule ^/(.*(\.js|\.ico|\.gif|\.jpg|\.png|\.css|\.html|\.htm|\.swf|\.flv))$ /$1 [L,I]
RewriteRule ^/(.*)$ /index.php/$1 [L,I]

Put this in your Zend Apps public folder. Note that the commented out rule is for ignoring css js and image files etc in your public folder so as not to get rewritten. However it messes with your GET parameters when you have a filename in the query.(IF anyone knows how to write a rule that say continue to route it if those extensions come after a question mark then PLEASE let me know!)

Restart IIS, and that should be you!

NB. Neither delboy1978uk nor anyone else endorses the use of IIS for any serious web development.

NB. I have found normal clean urls work but ?query=param gets dont! i will update once i fix this!

Password Protect folders in Apache with htpasswd

Want a completely insecure password protected folder using htpasswd?  Great!
A pointless exercise unless it’s in a setup at your work and you have no say in the matter, htpasswd’s are sent in unencrypted plain text, so anyone hanging around packet sniffing will pick up the password easily enough! Anyway, thats besides the point, how is it done?

First up we put this in the .htaccess for the directory we wish to protect (ha):

<Directory "/home/user/username/www/folder/to/protect">
AuthType Basic
AuthName "My Private Directory"
AuthUserFile "/path/to/htpasswd"
Require valid-user

Then we generate the htpasswd file like this:

 htpasswd -c /path/to/htpasswd username

Hooray! The illusion of ‘security’! At least it keeps non geeks out 😉