Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Feb 15, 2011 10:59 pm 
Offline
Senior Newbie

Joined: Tue Feb 15, 2011 10:51 pm
Posts: 7
Location: United States
I've done a lot of reading on these forums and elsewhere, but I can't seem to get mod_rewrite working on my Linode despite my efforts.

I have apache2 installed, have run 'a2enmod rewrite' and /etc/init.d/apache2 restart' multiple times, but I can't seem to get mod_rewrite to work.

I looked at my phpinfo page and mod_rewrite is listed as a loaded module.

However, when I try even the simplest Rewrite rules, they simply don't work.

Here is my .htaccess file located in /var/www/.htaccess
Code:
RewriteEngine on
RewriteRule ^2227/$ index.php?s=2227 [L]


When I visit /index.php?s=2227, my site loads fine, but visiting /2227 just brings me to a 404 page and my Apache error logs reflect this saying:
Code:
File does not exist: /var/www/2227

I have my chmod 775'd my .htaccess file.

Is there anything here that I'm missing or any reason at all why mod_rewrite wouldn't be working for me in this instance?


Top
   
 Post subject:
PostPosted: Tue Feb 15, 2011 11:24 pm 
Offline
Senior Member

Joined: Sun Apr 26, 2009 3:37 am
Posts: 72
Website: http://wiggenhorn.org/
It looks like your rewrite rule matches http://domain.com/2227/ (with a trailing slash), but you're requesting http://domain.com/2227 (without a trailing slash).


Top
   
 Post subject:
PostPosted: Tue Feb 15, 2011 11:28 pm 
Offline
Senior Newbie

Joined: Tue Feb 15, 2011 10:51 pm
Posts: 7
Location: United States
I've tried both with and without the trailing slash with no luck. :(


Top
   
 Post subject:
PostPosted: Tue Feb 15, 2011 11:31 pm 
Offline
Senior Member

Joined: Fri Jan 09, 2009 5:32 pm
Posts: 634
you're doing this in .htaccess, are you allowing that with AllowOverride in your main configuration? (either All or FileInfo)


Top
   
 Post subject:
PostPosted: Tue Feb 15, 2011 11:34 pm 
Offline
Senior Member

Joined: Sun Apr 26, 2009 3:37 am
Posts: 72
Website: http://wiggenhorn.org/
Maybe you need to add "AllowOverride All" to the appropriate <Directory> block in your apache configuration file (either apache2.conf, httpd.conf, one of the files in a place like /etc/apache2/sites-available/, or somewhere else), and then reload apache.


Top
   
 Post subject:
PostPosted: Wed Feb 16, 2011 2:31 am 
Offline
Senior Newbie

Joined: Tue Feb 15, 2011 10:51 pm
Posts: 7
Location: United States
I just tried adding the following to /etc/apache2/httpd.conf and restarting Apache with no luck:
Code:
<Directory /var/www>
     AllowOverride All
</Directory>

and (from http://mathiasbynens.be/notes/apache-allowoverride-all)
Code:
<Directory />
 Options FollowSymLinks
 AllowOverride AuthConfig FileInfo Indexes Limit Options=All,MultiViews
 Order deny,allow
 Deny from all
</Directory>


Is there anything else I could be missing?


Top
   
 Post subject:
PostPosted: Wed Feb 16, 2011 3:15 pm 
Offline
Senior Newbie

Joined: Tue Feb 15, 2011 10:51 pm
Posts: 7
Location: United States
Has anybody managed to get mod_rewrite working on their Linode boxes?


Top
   
 Post subject:
PostPosted: Wed Feb 16, 2011 3:16 pm 
Offline
Senior Member

Joined: Thu May 21, 2009 3:19 am
Posts: 336
mikepink wrote:
Has anybody managed to get mod_rewrite working on their Linode boxes?


Yes


Top
   
 Post subject:
PostPosted: Wed Feb 16, 2011 3:17 pm 
Offline
Senior Newbie

Joined: Tue Feb 15, 2011 10:51 pm
Posts: 7
Location: United States
What steps did you take to get it working?


Top
   
 Post subject:
PostPosted: Wed Feb 16, 2011 3:26 pm 
Offline
Senior Member

Joined: Thu May 21, 2009 3:19 am
Posts: 336
Thought you might want more detail :)

I'm running Debian, but that's what Ubuntu is based off of.

Code:
sudo a2enmod rewrite


That's it. I run a couple sites that have several different versions of Gallery installed and they are all using url rewriting without an issue.


Top
   
 Post subject:
PostPosted: Wed Feb 16, 2011 3:31 pm 
Offline
Senior Newbie

Joined: Tue Feb 15, 2011 10:51 pm
Posts: 7
Location: United States
I wish it were that simple for me :)

If anyone has time, would you mind looking at my phpinfo and seeing if there's anything glaringly wrong with it that might prevent mod_rewrite from working?
http://173.230.158.141/info.php


Top
   
 Post subject:
PostPosted: Wed Feb 16, 2011 6:46 pm 
Offline
Senior Newbie

Joined: Tue Feb 15, 2011 10:51 pm
Posts: 7
Location: United States
So I ended up running a2dismod and a2enmod with no luck, but what eventually worked for me is this:

removing /var/www/.htaccess
putting my rewrite rules in /etc/apache2/httpd.conf
editing my virtual hosts file to turn on the RewriteEngine and setting RewriteOptions to Inherit
restarting apache

This works, but everytime I want to change a rewrite rule, I need to restart Apache. It's not ideal, but it gets the job done.


Top
   
 Post subject:
PostPosted: Sat Feb 26, 2011 4:01 pm 
Offline
Senior Member

Joined: Wed Mar 03, 2010 2:04 pm
Posts: 111
I had rewrites working on my Ubuntu 9.10 linode and upgraded to 10.10 and they still work ok.

Since you got rewrites working in httpd.conf it is sort of looking like the module is being loaded but your .htaccess files aren't being read. Can you try other directives in .htaccess and see if they work?

In /etc/apache2/apache2.conf I have

AccessFileName .htaccess

I'm assuming you have that - but it's worth checking.

Then in my /etc/apache2/sites-available/ I have all my vhosts files. Inside those are the directives for each vhost. Inside the <Directory> sections in those files I have "AllowOverride All" for the vhosts that need .htaccess.

You might do a:

find /etc/apache2 | xargs grep "AllowOverride None"

just to see if anything in your Apache folder is turning overrides off? Hope that helps. I know this stuff can be kind of maddening (and writing the rules themselves can be an entire new, uh, "process"!)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
RSS

Powered by phpBB® Forum Software © phpBB Group