5

I installed WordPress on EC2, located in /var/www/html/wordpress. I followed the WordPress guide to copy index.php and .htaccess to root which is /var/www/html, and modified index.php and setting in admin panel. It works pretty well if I stick to only default link, such as: http://www.cubcanfly.com/?p=5, however other permalink options fails, actually all of the permalink options.

My .htaccess is

# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

in /etc/httpd/conf/httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so

is NOT commented.

Thanks in advance

LazyOne
  • 158,824
  • 45
  • 388
  • 391
HooYao
  • 554
  • 5
  • 19

3 Answers3

7

Finally I find the problem. It's the AllowOverride option in httpd.conf which is located in /etc/httpd/conf/httpd.conf, "sudo find / -name httpd.conf -print" can easily find it. I changed any AllowOverride NONE->ALL where i can find in the file. It just worked,even without doing any change to .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

This .htaccess works on my host in which wordpress is installed in its own directory.

Thank you @adlawson @Will, without you, I couldn't find the problem.

http://codex.wordpress.org/Using_Permalinks this official guide is quite enough to use permalink even wordpress is installed in a sub directory.

HooYao
  • 554
  • 5
  • 19
4

Have a look at this post How does RewriteBase work in .htaccess

You need to change RewriteBase / to RewriteBase /wordpress

Community
  • 1
  • 1
adlawson
  • 6,303
  • 1
  • 35
  • 46
  • 3
    And don't forget to change the last RewriteRule to /wordpress/index.php. – Will Jul 16 '11 at 15:52
  • @adlawson @Will I changed .htaccess to ... RewriteBase /wordpress...RewriteRule . /wordpress/index.php [L] and permalink still doesn't work, thanks for you help. – HooYao Jul 16 '11 at 17:21
  • @adlawson @Will thank you for your help, I finally find what going on here. I didn't enable AllowOverride in httpd.conf. Once i set it to All, it works pretty well with the .htaccess file I posted in the main thread.We don't actually need to do anything ^_^ cheers. – HooYao Jul 16 '11 at 17:55
0

I did not need to edit RewriteBase in .htaccess. The problem really is in httpd configuration for EC2 machines.

My .htaccess -

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

In /etc/httpd/conf/httpd.conf -

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

# 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
Syed Priom
  • 1,893
  • 1
  • 21
  • 22