views:

55

answers:

3

How would I rewrite script.php?id=3295 to script/3295??

and Im also wondering if someone could explain what these 3 RewriteConds does:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

Thank you very much

A: 
RewriteRule ^/sctipt/(.*) /script.php?id=$1
Saggi Malachi
+2  A: 

As I rather think that you want to rewrite requests of /script/3295 to /script.php?id=3295 and not the other way round, try this:

RewriteRule ^/script/([0-9]+)$ /script.php?id=$1

But if you really want to rewrite script.php?id=3295 to script/3295, try this:

RewriteCond %{QUERY_STRING} ^(([^&]*&)*)id=([0-9]+)&?([^&].*)?$
RewriteRule ^/script\.php$ /script/%3?%1%4

And if you want to use that rule in a .htaccess file, remove the leading slash from the pattern.

To your second question: The RewriteCond directives test if the requested URI cannot be mapped to an existing regular file (!-f), not to an existing directory (!-d) and not to an existing symbolic link (!-l).

Gumbo
A: 

For your first question, try:

RewriteRule ^script.php?id=(.*)$ /script/$1

For your second question, RewriteCond are conditions applied to the next RewriteRule. So if you see three RewriteCond like that all in a row, they all apply to only the next rule. The rule is only checked if all of those conditions match. In this particular case, it is checking the requested filename to make sure that it is not a file (!-f), not a directory (!-d) and not a symbolic link (!-l). If all of these conditions are true, mod_rewrite will process the next RewriteRule.

zombat