Rewrites in Ubuntu

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

I knew how to enable the rewrite in .htaccess while I was using Windows... click on the WAMP icon on the corner at the bottom-right and enable it in Apache menu... in Ubuntu, I can't seem to find a way to enable mod rewrite for Apache...

I've tried the following links and none of them gave me the solution...

http://ubuntuforums.org/showthread.php?t=255556

Here is what I've tried

Quote:
qwerty:~$ LoadModule mod_rewrite /usr/lib/apache2/modules/mod_rewrite.so
LoadModule: command not found
qwerty:~$ sudo apache2 -l
Compiled in modules:
core.c
mod_log_config.c
mod_logio.c
prefork.c
http_core.c
mod_so.c
qwerty:~$ a2enmod rewrite
Module rewrite already enabled


I also went to the 000-default thing and changed AllowOverRide None to AllowOverRide All and it still doesn't rewrite the URLs
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

I'm still looking for a solution here... anyone know how to fix this?
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

Open up your httpd.conf file and remove the hash from in front of the mod rewrite module.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

My httpd.conf is completely empty... 0 bytes :shock:


What should I do? I've never touched it, never used it, never knew it existed...

And Apache2.conf doesn't have anything about rewrite hashed or anything...
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

Did you restart the service after making any changes?
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Yes I did.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

On Ubuntu, Apache uses "apache2.conf" instead of "httpd.conf".

If you look towards the bottom of apache2.conf you'll see something like this.

Code: [ Select ]
# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
  1. # Include module configuration:
  2. Include /etc/apache2/mods-enabled/*.load
  3. Include /etc/apache2/mods-enabled/*.conf


You can see how the include directive works in Apache here. Note that the include directive is only available in server config, virtual host, and directory contexts. "apache2.conf" is considered server context. Also note that include is not a Ubuntu specific directive for Apache, Ubuntu just takes advantage of the include directive in order to organize things like port, module, and virtual host configurations.

Now if you look back at those two include directives I posted, you'll see "mods-enabled". If you look in the folder that "mods-enabled" is located in you'll also see a "mods-available" folder.

The way Ubuntu organizes Apache modules such as mod_rewrite is that it stores individual text files that each contain the LoadModule directives for each module available on the system in the "mods-available" folder.

If you look through some of the files in your "mods-available" folder, you'll see lines like this.

Code: [ Select ]
LoadModule cache_module /usr/lib/apache2/modules/mod_cache.so


Typically when you install a module on Ubuntu for Apache you're going to use something like this at the commandline.

Code: [ Select ]
sudo apt-get install libapache2-mod-php5


Which will save the *.so file where it needs to be, save a copy of the *.load file in the "mods-available" folder, and symlink that *.load file into the "mods-enabled" folder.

If you look at the contents of your "mods-enabled" folder, you'll see that there's not actually any files in that folder, only symlinks.

Now, that "a2enmod" you used earlier I'm assuming is suppsed to enable modules. The first result I found for it in relation to Ubuntu was someone talking about it not working though.

I can't tell you anything other than that about a2enmod, because I don't use it. Every module I've ever needed was included with Apache when I installed it on Ubuntu.

I track down the *.load file of the module I want to enable in "mods-available", and symlink it into my "mods-enabled" folder.

Code: [ Select ]
sudo ln -s /etc/apache2/mods-available/expires.load /etc/apache2/mods-enabled/expires.load


Then restart (always restart, never reload) Apache.

Code: [ Select ]
sudo /etc/init.d/apache2 restart


--

Now, if you look in your "mods-enabled" folder and see a symlinked "rewrite.load" file, then assuming you've restarted Apache already then mod_rewrite is as loaded as it's going to get.

If it doesn't seem to be working, check the contents of your error log

Code: [ Select ]
/var/log/apache2/error.log


and see if Apache is complaining about anything at start up.
There man be other notices that could help in the error log as well.

--

What do the rewrites you're trying look like? Are you including a "RewriteEngine on" anywhere?

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 64 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
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.