Koozali.org: home of the SME Server

The eternal "how-to-activate-htaccess-files" probl

countzero

The eternal "how-to-activate-htaccess-files" probl
« on: August 12, 2007, 06:09:33 AM »
To jumpstart this topic:

(Am using SME 7.2 and PHP5/MySQL5)
Create a new ibay (I will use "wordpress" in this example).
Code: [Select]
db accounts setprop wordpress AllowOverride All
db accounts setprop wordpress FollowSymLinks enabled
signal-event ibay-modify wordpress
/etc/rc.d/init.d/httpd-e-smith restart

Now .htaccess files for this ibay should have effect as everybody keeps telling me.

To test this:
1) Remove the index.html file inside the newly created ibay (not necessary, but it makes things foolproof)
2) Create a .htaccess file containing:
Code: [Select]
RewriteEngine On
3) Check the permissions of the .htaccess file.
4) http://yourdomain.com/wordpress
  If you get a 500 Internal Server Error, mod_rewrite is not enabled.
  Your Apache conf should contain "LoadModule rewrite_module modules/mod_rewrite.so" (it does by default)
5) Add to the .htaccess file:
Code: [Select]
RewriteRule ^(.+)\.html$ $1.php
This will translate all request as follows:
yourdomain.com/wordpress/foo.html -> yourdomain.com/wordpress/foo.php

To test, create a foo.php file in your ibay containing:
Code: [Select]
<?php
  phpinfo
&#40;&#41;;
?>

Check permissions.
Now try to access this file using http://yourdomain.com/wordpress/foo.html

====

However, I continuously get:

Code: [Select]
Not Found
The requested URL /home/e-smith/files/ibays/wordpress/html/foo.php was not found on this server.

countzero

The eternal "how-to-activate-htaccess-files" probl
« Reply #1 on: August 12, 2007, 06:27:59 AM »
I have just verified the above procedure using WAMP on Windows.
Here, it all works properly.

From the above error output I conclude that the .htaccess DOES WORK as the error message states "foo.php" and not "foo.html".  However, the base URL seems to be replaced by the base Dir.  I suspect there is some SME magic at work here that I don't know about yet.

=======
SOLUTION
=======
When I change
Code: [Select]
RewriteRule ^(.+)\.html$ $1.php
into
Code: [Select]
RewriteRule ^(.+)\.html$ http://yourdomain.com/wordpress/$1.php [R]
it however does work (hoorah!)

To test go here: http://coeleveld.com/imodrewrite

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: The eternal "how-to-activate-htaccess-files" p
« Reply #2 on: August 12, 2007, 02:41:07 PM »
Quote from: "countzero"
To jumpstart this topic:

(Am using SME 7.2 and PHP5/MySQL5)
Create a new ibay (I will use "wordpress" in this example).
Code: [Select]
db accounts setprop wordpress AllowOverride All
db accounts setprop wordpress FollowSymLinks enabled
signal-event ibay-modify wordpress
/etc/rc.d/init.d/httpd-e-smith restart

Restarting your webserver should not be necessary as this should be taken care of by the ibay-modify event.

The description might be good to post in the wiki in the Howto section but IMHO you really do not need .htaccess files on SME Server as you can modify the configuration template on a per ibay basis to include stuff like this.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)