20

I have just transferred my blog from my local webserver to Amazon EC2 Free Linux server, Everything seems to be working now except for permalinks, I disabled and re-enabled them and it still breaks.

I've tried running the script

sudo a2enmod rewrite

But it says a2enmod: command not found while logged into my server as ec2-user

Any help would be much appreciated!

Thanks

8 Answers 8

44

I just had this same issue and, assuming you are using httpd, you will need to go to /etc/httpd/conf then open http.conf by running sudo vi httpd.conf and then change "AllowOverride" to:

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

You may also need to change AllowOverride All here:

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride All

Then you need to restart httpd by running apachectl -k restart. Note, you may need to actually run sudo apachectl -k restart.

Let me know if that helps.

3
  • 1
    Hey Carl, can't thank you more! especially the sudo apachecl -k restart part. Couldn't find that on other sources and was so frustrated... Thanks!
    – alexweberk
    Nov 30, 2013 at 18:32
  • apachectl -k restart didn't work for me, but sudo service httpd restart did
    – jaressloo
    Apr 21, 2015 at 19:15
  • Had a friend with a similar issue, and her configuration was slightly different. Her wordpress install was in var/www/html/, and there was an AllowOverride None directive in the directory block for that specific directory. In that case, you'll need to set the AllowOverride directive to All in the directory block for that specific folder - And I'd recommend leaving it to None for the other directory blocks that aren't using wordpress. Jan 29, 2018 at 5:37
2

For Ubuntu, change the "AllowOverride All" at the following location:

"The additional step I had to take was to edit /etc/apache2/sites-enabled/000-default.

In that file you'll find an AllowOverride setting for /var/www, saying "None".

Change the setting to say: AllowOverride All "

Credit to ljonas @ http://wordpress.org/support/topic/solved-permalinks-working-in-apache2-ubuntu-1010

2

There are written and video instructions located here https://a1websitepro.com/enable-pretty-permalinks-amazon-web-hosting/

    <Directory /var/www/html/>
     Options Indexes FollowSymLinks
     AllowOverride All
    </Directory>
1
  • The linked instructions explains that .htaccess has to be edited. Other posts suggest that it's just apache2.conf Sep 6, 2020 at 4:58
2

Basic: Connecting to Your Linux Instance from Windows Using PuTTY

Step 1: Open PuTTY to login in AWS EC2 console

Step 2: Enter Server Address

enter image description here

Step 3: Browse Auth Private Key in PuTTY

enter image description here

Step 4: Login to AWS through PuTTY (Enter “Login as name” i.e. your AWS ec2 instance name. for above example: ec2-user)

Step 5: Change directory to /etc/httpd/conf ($ cd /etc/httpd/conf)

Step 6: execute sudo vi httpd.conf to update httpd.conf file. (Open httpd.conf file in VI editor)

Update Following

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

To

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

And

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride None

To

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#

    AllowOverride All

Step 7: Save and Exit from VI editor.

To save and exit from VI editor press [Esc] key and type :wq

Step 8: Restart Apache

Type sudo apachectl -k restart

Final Screenshot

enter image description here

1

On AWS my file was in a slightly different location:

sudo nano /etc/httpd/conf/httpd.conf

After changing AllowOverride None to AllowOverride All in both locaitons and restarting with sudo service httpd restart permalink redirects work great!

0

Your server may not have the AllowOverride directive enabled. If the AllowOverride directive is set to None in your Apache httpd.config file, then .htaccess files are completely ignored.

In this case, the server will not even attempt to read .htaccess files in the filesystem. When this directive is set to All, then any directive which has the .htaccess Context is allowed in .htaccess files. Example of enabled AllowOverride directive in httpd.config:

Options FollowSymLinks

AllowOverride All

This link may also be helpful: http://codex.wordpress.org/Using_Permalinks

0

AllowOverride controls what directives may be placed in .htaccess files. It can be "All", "None", or any combination of the keywords: Options FileInfo AuthConfig Limit

AllowOverride All

when i set this on my server, then i got 503 internal server error, any advi please?

0

I had to use the AllowOverride All and Options +FollowSymLinks in more than one .conf file (and I also tried a2enmod rewrite while I was at it). But it was the last .conf file that was apparently controlling that directory (the .iso we used resulted in several with the same directory ... and the first one I changed had no effect). But once they ALL had both those settings the system began working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.