
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlug] [OT] Creating user-friendly URLS with mod_rewrite/Apache [SOLVED]
Josh,
Thank you for your help.
I'm happy to report that the issue is solved. I am getting nice friendly
URLs, so mod_rewrite seems to be working.
It should be noted, though, that even though mod-rewrite is working, it
isn't listed when I run "/usr/sbin/apache2 -l". I don't know if that's
odd behaviour or not, just that it seemed like it was supposed to be
listed there.
For my own reference as well as others, although the path to the answer
was a little stumbly, here are the steps that I think ultimately lead to
getting everything to work:
1. # sudo a2enmod rewrite
2. Confirm that the "rewrite.load" file is in /etc/apache2/mods-enabled
Currently I have the following files in that directory:
cgi.load php5.conf php5.load rewrite.load
3. # sudo gedit /etc/apache2/sites-available/default
Find where it says:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
And change "AllowOverride None" to "AllowOverride all". (I noticed that
"None" was in upper case, and "all" was lowercase. Don't know if case is
important, but this is the way that it worked for me).
Some sites said to edit /etc/apache2/sites-enabled/000-default, or
sometimes "default-000", but they are just symlinks to
/etc/apache2/sites-available/default (at least in my case).
4. # sudo gedit /etc/apache2/httpd.conf
Add the following lines:
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
No other editing of httpd.conf was necessary, despite some sites that
said to use "LoadModule".
5. Reload the apache modules and restart Apache.
# sudo /etc/init.d/apache2 force-reload
# sudo /etc/init.d/apache2 restart
6. Create an .htaccess file (if there isn't one already) in the
directory where one wants to create "user friendly URLS", and add the
following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
As David explained, this should set it so that "If the requested URI
matches a real file or directory, proceed as normal. If not, call
index.php (or whatever you set it to) which then needs to take care of
the request one way or the other (for example send 404 if it's a missing
image file)"
If anyone can see problems in the above, or if I've misunderstood some
part, please let me know.
Thanks to Josh, David, Godwin, Stephen, Romans, Edmund, and all of TLUG
for their ever-present great support.
--
Dave M G
Home |
Main Index |
Thread Index