views:

18

answers:

2

First question, here goes nothing...

I'm trying to add a new entry to my .htaccess file (Apache server) with the hopes of translating this URL:

http://platform.localhost/category.all

into this URL:

http://platform.localhost/index.php?page=category.all

The RewriteRule that I'm currently using is this:

RewriteRule ^([^/\.]+)\/?$ index.php?page=$1

This rule has worked fine for all URLs up until now, I can only assume that it is the period that is breaking it.

What I'm trying to achieve is having anything in the URL after the "http://platform.localhost/" passed into the "page" variable of index.php.

I know I've missed something stupid, can someone please be kind enough to point it out?

Cheers

+2  A: 

the pattern says to reject dots, but you could do tis:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]
jspcal
Excellent, thank you. Worked perfectly.Answer accepted.
GlenCrawford
A: 

Why not just something like:

  RewriteRule index.php - [L]
  RewriteRule (.*) index.php?$1

This might fail because I don't remember exactly if querystrings are included when matching against the pattern, so I'm not sure what would result if you'd request:

http://bla.blub/x?q=1

Also note that this is for a .htaccess/directory context.

zedoo