Stack,
I'm trying to install a local version of my website onto my laptop so I can do development work without terrifying my users and exploding the live site.
I went ahead and installed ubuntu on my laptop along with apache/mysql/php and downloaded my php files and database from my web server onto my laptop.
I went ahead and changed my etc/hosts file so my website domain name now points to my localhost and that seems to be working great.
However, for the life of me, I can't get my htaccess mod_rewrite directives to work. It is very frustrating because I know mod_rewrite is working since I went though a tutorial on turning it on in ubuntu (the tutorial included a simple test case to make sure it was running properly). The htaccess code works perfectly on my actual web server, but it just won't work on my local ubuntu install.
But enough talk, I'll let you see what I have in the htaccess file to whet your appetite:
# To set your custom php.ini, add the following line to this file:
# suphp_configpath /home/yourusername/path/to/php.ini
AuthUserFile /var/www/.htpasswd
AuthType Basic
AuthName "not allowed"
<Files ".htaccess">
Require valid-user
</Files>
<Files "uploadpage.php">
Require valid-user
</Files>
<Files "upload.php">
Require valid-user
</Files>
ErrorDocument 404 /404.php
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^random/([0-9]+)/(.*)$ random.php?id=$1
RewriteRule ^new/([0-9]+)/(.*)$ new.php?id=$1
RewriteRule ^quickviewrandom/([0-9]+)/(.*)$ quickviewrandom.php?id=$1
RewriteRule ^quickviewnew/([0-9]+)/(.*)$ quickviewnew.php?id=$1
RewriteRule ^archive/previous-30-days/$ archive/previous-30-days.php
RewriteRule ^archive/previous-12-months/$ archive/previous-12-months.php
RewriteRule ^user/profile/(.*)/$ user/profile.php?username=$1
RewriteRule ^post/([0-9]+)/(.*)$ post.php?id=$1&%{QUERY_STRING}
RewriteRule ^direct/([0-9]+)/(.*)$ direct.php?id=$1
RewriteRule ^comments/([0-9]+)/(.*)$ comments.php?id=$1&%{QUERY_STRING}
RewriteRule ^top/([0-9]+)/$ top.php?page=$1
RewriteRule ^topweek/([0-9]+)/$ topweek.php?page=$1
RewriteRule ^fresh/([0-9]+)/$ fresh.php?page=$1
RewriteRule ^user/submitform/$ user/submitform.php
RewriteRule ^user/submit/(.*)/([0-9]+)/$ user/submit.php?username=$1&postlimit=$2
RewriteRule ^user/usercomments/(.*)/([0-9]+)/$ user/usercomments.php?username=$1&commentlimit=$2
RewriteRule ^user/favorites/(.*)/([0-9]+)/$ user/favorites.php?username=$1&favlimit=$2
RewriteRule ^user/friends/(.*)/([0-9]+)/$ user/friends.php?username=$1&friendlimit=$2
RewriteRule ^user/inbox/([0-9]+)/$ user/inbox.php?maillimit=$1&%{QUERY_STRING}
RewriteRule ^user/message/([0-9]+)/$ user/message.php?stackid=$1
RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]
RewriteCond %{QUERY_STRING} img_name=(.*)
RewriteRule ^new\.php$ http://www.mydomain.com/404.php [R=301]
RewriteRule ^page\.php$ http://www.mydomain.com/404.php [R=301,L]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
Any thoughts on what I should try? Seriously, I'm open to anything at this point.
Strangely enough this rewrite rule works:
RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]
This was part of the tutorial I did for setting up mod_rewrite in ubuntu. The rest of the rules are my rules that are not working :-(
Running a separate development server space, along with other items such as proper use of version control are a sign of a serious programmer, so you are to be commended and reminded that the pain you spend getting this right is better than the pain of mistakes made while developing on a live site.
In this case obviously there is an assumption being made somewhere which does not correspond to reality, some difference between the live and development environments. Keeping that in mind, I would build up from the example that does work and slowly add in conditions, tweaking until the next most complex thing works, looking for the clue as to what may be amiss.
Try some simple rules with the RewriteCond. Try without the RewriteBase directive. Try with and without the leading anchor "^".