I have the following .htaccess file:
RewriteEngine on RewriteBase / RewriteRule ^(/?)dir/?$ $1dir/subdir [L] RewriteRule ^(/?)subdir2/?$ $1dir/subdir/subdir2 [L]
The redirecting works fine, if I type in the IP of the domain, but typing in the domainname/dir doesn't redirect me at all, instead shows me the content of the directory.
Another question: As I said, the redirecting with the IP works fine. However, although the 'R' flag is not set, the url changes in the url box. IP/dir changes into IP/dir/subdir. Why?
EDIT (11:20 GMT+1): Not quite sure if it's of any relevance, but before today the server didn't have a domain. I just bought a domain and set up all the nameserver pointing to the server up. Since I can access the page and it shows me the content of the /dir folder, I assume that I didn't mess up anything there.
EDIT (12:51 GMT+1): Output from apachectl -S:
apache2: Could not reliably determine the server's fully qualified domain name, using 0.0.10.188 for ServerName VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers: *:80 is a NameVirtualHost default server 0.0.10.188 (/etc/apache2/sites-enabled/000-default:1) port 80 namevhost 0.0.10.188 (/etc/apache2/sites-enabled/000-default:1) Syntax OK
EDIT (19:26 GMT+1): Found the problem. The problem was that my server name was not set and I had duplicates in ports.conf and httpd.conf, both where "listening". Thanks for pointing out the "apachectl -S" command. One mysterious problem left: Why is the url changing, although no R flag is set. Forever a mystery...