Htaccess problems
I have this .htaccess file that doesn't work when I start with getgage.local / category / gages / part of this array doesn't go through
RewriteEngine On
RewriteRule ^/category/(.*?)/$ category.php?p=$1 [rn]
For testing the category.php file, just dumping $ _POST, $ _GET and $ _SERVER is what I see when I open the page.
GET
Array ( )
POST
Array ( )
SERVER
Array (
[HTTP_USER_AGENT] => Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.59 Safari/525.19
[HTTP_ACCEPT_ENCODING] => gzip,deflate,bzip2,sdch
[HTTP_ACCEPT] => text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
[HTTP_CACHE_CONTROL] => max-age=0
[HTTP_ACCEPT_LANGUAGE] => en-US,en
[HTTP_ACCEPT_CHARSET] => ISO-8859-1,*,utf-8
[HTTP_HOST] => gotgage.local
[HTTP_CONNECTION] => Keep-Alive
[PATH] => /usr/local/bin:/usr/bin:/bin
[SERVER_SIGNATURE] => Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4.2 with Suhosin-Patch Server at gotgage.local Port 80
[SERVER_SOFTWARE] => Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4.2 with Suhosin-Patch
[SERVER_NAME] => gotgage.local
[SERVER_ADDR] => 192.168.0.180
[SERVER_PORT] => 80
[REMOTE_ADDR] => 192.168.0.196
[DOCUMENT_ROOT] => /home/gotgage/www/
[SERVER_ADMIN] => [no address given]
[SCRIPT_FILENAME] => /home/gotgage/www/category.php
[REMOTE_PORT] => 56793
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /category/gages/
[SCRIPT_NAME] => /category.php
[PATH_INFO] => /gages/
[PATH_TRANSLATED] => /home/gotgage/www/gages/
[PHP_SELF] => /category.php/gages/
[REQUEST_TIME] => 1241579116
[argv] => Array
(
)
[argc] => 0 )
The redirect technically works, however I am not getting the vars on the page below that the dumping is correct from the correct page, but my vars are not being transferred.
a source to share
Well it worked for me. Seems like I didn't like leading errors /
and [rn]
for me syntax errors.
RewriteEngine On
RewriteRule ^category/(.*?)/$ category.php?p=$1
Note: it should be anyway [R,N]
, but again, in this case they are not needed.
RewriteRule Flags Documentation - shows why you probably didn't want to use R
or N
, but there may be something we don't know.
RewriteRule Documentation - Doesn't seem to indicate the leading /
RewriteRules in .htaccess (if there is a RewriteBase). Anyway, try the rule with and without /
, for me it only works without it.
a source to share
There are a few things that are somewhat unclear:
1) What was the relevant match against the regex part:
(.*?)
This is a bit overkill - if you just want to match anything between the forward slashes, suffice:
(.*)
2) You are setting the 'rn' flag which is not valid. An example of valid flags:
[R] [N] [R,N]
although, I'm not sure if you really want to use R and N together.
a source to share