1

I have moved a site from one host to another, and in doing so came across the trap of failing to download my .htaccess file in the process.

I am attempting to rebuild said .htaccess based on an earlier (possibly non-working) saved copy, but all I've been getting is 404 pages. In other words, something is wrong with this simple rewrite rule, but I assume mod_rewrite is working properly, as I'm no longer seeing "internal server error 500" type errors and other vhost sites are operational with mod_rewrite on the same machine.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([^/.]+)/?$ index.php?page=$1 [L]
</IfModule>

A sample (actual, working) page from my site:

site.com/index.php?page=tips

All of my links, and hopefully address bar should be in this form:

site.com/tips/

I thought I understood this; it isn't terribly complex. I've mangled and troubleshot the RewriteRule line to a variety of combinations based on various websites' suggestions. I have googled for two days and found some things that are close to what I'm doing, but no exact matches. Every time I make a change, I've been restarting apache service on the server, going to Chrome on my local machine and hitting Ctrl+F5 to clear cache and refresh; is there any chance I'm missing a "clean reload" step?

The entire site takes place through index.php, and I'm not planning to complicate things with further nesting until I understand regex much better. Any help is greatly appreciated!

Side notes: I'm on Apache v2.2.22, and I can't seem to get this version's "RewriteLogs" feature working (not using .htaccess for this, of course) or I wouldn't have posted this noob question today. In 2.4, this feature is no longer valid anyways (logging got a total overhaul), but I can't seem to upgrade to that yet using apt-get on my OpenVZ Ubuntu 12.04 x64 server.

1 Answer 1

0

It ended up being that mod_rewrite was not enabled on my server. I checked this by placing a phpinfo.php file in the site's directory and checking the "Loaded Modules" section for mod_rewrite, which was indeed missing.

I enabled mod_rewrite with sudo a2enmod rewrite, checked the list of modules again with apache2ctl -M, and everything started working again.

Even more strangely, mod_rewrite somehow turned itself off for the whole server, not just these pages. Given that I was serving other sites using their own respective .htaccess files and they were also not functioning (which is what clued me in to this), I'm glad I found this out relatively quickly.

I also learned that Ubuntu has its own group for apache update approval/testing, and they have not yet qualified Apache's 2.4 patch, and it could be a long while since somewhat significant changes were brought forth with it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .