1

Given the following setting I would like to do a mod_rewrite which I can not get to work:

I have a domain e.g. "example.org" pointing to a directory in a shared hosting environment e.g. example/ with the following file structure:

example/
    index.php
    .htaccess

Now a URL like example.org/test should be rewritten to example.org/index.php?p=test. What I came up with is the following:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]+)$ index.php?p=$1 [L,QSA]

Unfortunately opening e.g. example.org/test in Firefox results in the following error:

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

  • This problem can sometimes be caused by disabling or refusing to accept cookies.

It works though, if I prefix the matching part like this:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^prefix/([a-z]+)$ index.php?p=$1 [L,QSA]

Then I can open e.g. example.org/prefix/test and am served with index.php?p=test although additional resources like CSS and JavaScript are not correctly referenced.

Who can help?

4

0 回答 0