views:

160

answers:

5

I am a newb to PHP. Can anyone tell me what each line does here. Do I need this? It is giving me errors

RewriteCond %{REQUEST_URI} /~([^/]+)/?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /~%1/rewrite.php?p=$1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_URI} /~([^/]+)/?
RewriteRule ^index\.php?(.*)$ /~%1/rewrite.php?p=%1&%{QUERY_STRING} [L]
#there is no ~ character in the URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) ./rewrite.php?p=$1&%{QUERY_STRING} [L]
RewriteRule ^index\.php?(.*)$ ./rewrite.php?p=$1&%{QUERY_STRING} [L]
#WJ-180 fix
RewriteRule ^resume\.php?(.*)$ ./rewrite.php?p=resume\.php$1&%{QUERY_STRING} [L]
+2  A: 

If you are new, please read http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html, it is explained very nicely.

p.s. Your title "What do these declarations mean in my PHP .htaccess file?" is incorrect, .htacces is not php file.

glavić
A: 

Those are mod_rewrite configuration entries.

Randolpho
A: 

It an Apache mod_rewrite rule. Unless you are using some sort of framework you probably don't need it. See Apache mod_rewrite for more info.

zodeus
A: 

The simple answer: These declarations rewrite every request to a rewrite.php file.

The more comprehensive answer: The RewriteCond and RewriteRule directives are from the Apache module mod_rewrite and provide a rule based URL rewrite mechanism.

It seems that these rules are intended to rewrite every request to a rewrite.php file, either in a specific directory (/~foobar/rewrite.php) or in the root (/rewrite.php).

Gumbo
+1  A: 

These say

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

"Only use the following rule if the request does not match an existing file or directory."

Daniel Von Fange