Htaccess rewriting goes to a loop

Well, I was trying to use the following in htaccess, but I get the message of redirect loop.


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]

What I want to do is this:
The URL is like name.somedomain.com/somepage/s1/s2
The index.php is accessible from name.somedomain.com/somepage/
I want to send s1/s2 as $_GET[‘page’]
Also, I don’t want the URL in the address bar to change, only the url sent to the server should change.
This worked well in my localhost, but on webserver (0fees.net), it doesn’t work

That really should work. Where is the .htaccess file located?

Could you try this:


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /somepage/index.php?page=$1 [L,QSA]

(replace somepage with the actual name of course)

Changed, but nothing happened.
The URL loops around to something like this:

[
http://some.domain.net/www/some.domain.net/index.php?page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/index.php&page=www/some.domain.net/social2/index.php&page=authenticate/login

ScallioXTX was right. What you posted should work. The real problem is almost certainly coming from elsewhere. You’ll have to show your entire htaccess file. It’s also important to know where that htaccess file lives and whether there are other htaccess files.

ErrorDocument 404 /index.php
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]
</IfModule>

This is my entire .htaccess file

max,

THINK like a server: somepage/s1/s2 won’t exist as a file or directory so somepage/s1/s2 will be sent to index.php as the value of page in the query string. (with your code). Note, though, that this code should be in your somepage directory so this is why Rémon’s solution won’t work.

Whenever possible, I prefer to put all my mod_rewrite in the DocumentRoot where Rémon’s solution would work (without the leading / in the redirection - that causes the server to look to its root first then you your DocumentRoot).

Note, too, your ErrorDocument is to your DocumentRoot’s 404 script (/index.php) which is NOT the same as used in your RewriteRule. Was this intentional?

Lastly, [standard rant #4][indent]The definition of insanity is to repeatedly do the same thing expecting a different result. Asking Apache to confirm the existence of ANY module with an <IfModule> … </IfModule> wrapper is the same thing in the webmaster world. DON’T ACT INSANE! If you don’t know whether a module is enabled, run the test ONCE (without the wrapper) then delete it permanently as it is EXTREMELY wasteful of Apache’s resources (and should NEVER be allowed on a shared server).[/indent][/standard rant #4]

Regards,

DK