views:

19

answers:

1

I have a VirtualHost setup like this :

Alias /somedir /some/other/dir

http://example.com/somedir works fine

However, I need to setup mod_rewrite for /somedir (a CodeIgniter app for which I want clean URLs). Here's the bit from the CodeIgniter wiki :

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

Usually, when mod_rewrite is used in subdirs changing RewriteBase to match the name of the dir is enough to make it work :

RewriteBase /somedir

...but it doesn't seem to work with mod_alias (getting 404s). Is there a workaround for this problem ?

A: 

The following worked on my test server, so trying this might solve your problem..

In your virtual host:

Alias /somedir /some/other/dir

RewriteEngine On

# I think these conditions should work correctly; the other ones shouldn't
# because the alias has not been applied at this stage of processing yet
RewriteCond /some/other/dir%{REQUEST_URI} !-d
RewriteCond /some/other/dir%{REQUEST_URI} !-f
# L is unnecessary in this context, but be sure to PT so mod_alias picks up
# on the rewrite
RewriteRule ^/somedir/(.*)$ /somedir/index.php/$1 [PT]
Tim Stone
Thanks, but it's still not working... I've tried putting it in `.htaccess`, at the root of the aliased dir, in a `<Location>` block in the vhost config, still no go.
Andrei
Did you try putting it in the vhost config outside of any `<Location>`/`<Directory>` blocks? I'll test with the `.htaccess` later though and see if I can figure out why that might not be working either.
Tim Stone