Forum Moderators: phranque
Here is my url:
http://www.domain.com/review/comments/review_comments.php?item_id=8&review_id=16&PHPSESSID=41b01225c36a863a9528e03062a0771d Here is the contents of my .htaccess file:
php_value error_reporting 2047
php_value display_errors 0
php_flag session.use_trans_sid offOptions +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^index2/(.*).php /review/index2.php?item_id=$1 [QSA,L]
RewriteRule ^review_categories_yahoo_cats2/(.*).php /review/review_categories_yahoo_cats2.php?category=$1 [QSA,L]
RewriteRule ^(.+)\.html$ $1.php [QSA,L]
Several questions:
1. Should that code work on all servers running apache/php?
2. Is there a way to write that code better?
3. I'm very confused on how to add the url example that is a couple directories deep and has two variables in the url. How would I write that?
Thanks in advance!
Tim
Here is my url:[domain.com...]
Here is my script filepath:/review/comments/review_comments.php?item_id=8&review_id=16&PHPSESSID=41b01225c36a863a9528e03062a0771d
Now the question becomes, "What URL do you want to rewrite that script filepath?
The code you posted is unclear, since it's not obvious what the "exists" checks on the first rule are for. And be aware that those "exists checks" only apply to that first rule, not the ones that follow.
In general, you could code something like:
RewriteRule ^index2/([^/])/([^.]+)\.php$ /review/index2.php?item_id=$1&review_id=$2 [QSA,L]
to rewrite requests for example.com/index2/<item_id>/<review_id>.php to your script at /review/index2.php with a query string of item_id=<item_id>&review_id=<review_id>
Jim