On Apr 22, 2008, at 05:57, Emil Edeholt wrote:
Hello!
I've been trying to make my urls look like site.com/foo instead of
site.com/index.php?page=foo so I have one rewriterurl that
rewrites /foo to my php script and one rule that redirects old
index.php-url:s to my new urls. When I apply both rules they end up
in an infinite loop that I just can't get to stop. I've tried
adding a lot of different conds, but I can't get it to work.
# If the url does not contain index.php rewrite to index.php script
RewriteCond %{REQUEST_URI} !index\.php
RewriteRule ^([a-z_]*)$ index.php?page=$1 [L]
# If the url does contain index.php redirect to /foo
RewriteCond %{REQUEST_URI} index\.php
RewriteCond %{QUERY_STRING} page=([a-z_]*)
RewriteRule ^index.php$ /base/path/%1? [R=301,L]
Any ideas?
Well, it's doing what you told it to do - if it's for /foo it
redirects it to index.php?page=foo and if it's index.php it redirects
it to /foo
While I understand what you're trying to accomplish - only letting
people see the "/foo" version - this just isn't going to work,
particularly not in a .htaccess file. Your best bet is to drop the
second ruleset, and just ensure that all HTML links contain the
desired URL rather than the actual one.
It's possible (I haven't tested this, not certain) that if you are
able to move this to the main configuration file, and add a [PT] to
the first ruleset and a [NS] to the second ruleset, that it'll do
what you mean. But I rather suspect not.
--
"There are two kinds of light--the glow that illuminates, and the
glare that obscures."
James Thurber