Forum Moderators: phranque
I got
Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^directory/([^.]+)$ directory/index.php?title=$1 [L]
And
domain.com/directory/Widget_101
works, but
domain.com/directory/Widget.101
doesn't.
It's a wiki script, so I can't keep visitors from having files created with periods!
RewriteRule ^directory/([^.]+)\.([^.]+)\.([^.]+)$ directory/index.php?title=$1.$2.$3 [L]
RewriteRule ^directory/([^.]+)\.([^.]+)$ directory/index.php?title=$1.$2 [L]
doesn't fix it. Server tries to redirect over and over until it gives up.
RewriteRule ^directory/(.*)$ directory/index.php?title=$1 [L]
also doesn't work, even with out the period. It also tries to redirect until it gives up.
This is because, for security and other reasons, it is necessary to re-start the configuration code on the server after any rewrite, so that the newly-rewritten URL can be tested against access controls such as hotlink protection and password protection, other "rewrites" such as ScriptAliases, etc.
The simple solution is to exclude the new URL from being re-rewritten by specifically testing for it before the rewrite.
Taking your second rule as an example, the problem is that "directory/index.php?<any query> matches the pattern "^directory/([^.]+)\.([^.]+)$" and so will be rewritten recursively. So you need to prevent that from happening:
RewriteCond %{REQUEST_URI} !^/directory/index\.php
RewriteRule ^directory/([^.]+)\.([^.]+)$ directory/index.php?title=$1.$2 [L]
Jim