views:

114

answers:

2

Hey

I have this htaccess code:

RewriteEngine on
RewriteBase /xm/
RewriteCond %{REQUEST_URI} !^/index.php$
RewriteRule ^([a-z0-9]*)\.php$ index.php?page=$1

And I want that when the user goes to, for example, main.php, that this htaccess redirects to index.php?page=main, but every time, and with every page, it redirects to index.php?page=index, and page is equal index no matter what. What am I doing wrong?

EDIT: works fine with numbers (eg 4.php) but not with letters :/

+1  A: 

It's rewriting again on the subrequest. Put [NS] to the right of it so it'll only get rewritten once.

chaos
RewriteRule ^([a-z0-9]*)\.php$ index.php?hash=$1 [NS]still only getting index :/
Xunil
Well, that's how I've always fixed this sort of thing. Do you maybe have some other rewriting directives in operation that could be affecting your requests?
chaos
A: 

Try this:

RewriteCond $1 !^index$
RewriteRule ^([a-z0-9]+)\.php$ index.php?page=$1
Gumbo
Worked perfectly, thanks :D
Xunil