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
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.
Have a look at this post How does RewriteBase work in .htaccess
You need to change RewriteBase / to RewriteBase /wordpress
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
Related
I have a subdirectory (app) I want to access that is in the root folder of my wordpress site. I have looked here:
https://wordpress.stackexchange.com/questions/20152/cannot-access-non-wordpress-subdirectories-as-wordpress-overrides-them-with-a-40
I have tried the solutions and nothing worked.
I also tried adding a separate .htaccess file to the app subdirectory that looks like this:
DirectoryIndex index.php index.html index.htm
Options +Indexes
But it didn't seem to help:
The main .htaccess I am trying with now looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/app/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
# 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>
# END WordPress
I get a 404 error.
What am I doing wrong? If I am viewing the site on an iPhone, is clearing the safari history on the phone enough to refresh the data so it recognizes the new .htaccess? Thanks.
UPDATE
I added:
<Directory "/home/eamondev/public_html/subconscious/">
Options All
AllowOverride All
Require all granted
</Directory>
to a .conf file that gets Includeed in httpd.conf, restarted apache, but didn't help.
I also tried:
<Directory "/home/eamondev/public_html/subconscious/">
AllowOverride All
</Directory>
and it didn't work, I'm not sure if I only need AllowOverride All - either way this doesn't seem to help.
UPDATE
In a .conf file that is Included in httpd.conf, I tried:
<VirtualHost 162.241.180.99:80>
ServerName eamondev.com
DocumentRoot /home/eamondev/public_html
<Directory "/home/eamondev/public_html/">
AllowOverride All
</Directory>
</VirtualHost>
but it didn't help.
Is there any reason I shouldn't just make another subdomain on my server and host the files out of there so reaching them doesn't conflict with my wordpress site?
Use below code i think it will work.
<IfModule mod_rewrite.c>
RewriteEngine On
# Map http://www.example.com to /app.
RewriteRule ^$ /app/ [L]
# Map http://www.example.com/x to /app/x unless there is a x in the web root.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/app/
RewriteRule ^(.*)$ /app/$1
# Add trailing slash to directories within app
# This does not expose the internal URL.
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^app/(.*[^/])$ http://www.example.com/$1/ [R=301]
</IfModule>
Turns out, my domain hadn't propagated yet, so it wasn't possible to see/test any of the changes I was making. Before I realized that it was still propagating, I also thought to just create another subdomain and host the files I needed to from there.
This is a frequently asked question, but after searching for hours I couldn't find any solution that worked for me. So, here's my problem:
When I change my permalinks setting to 'postname' I get a 404 Error when I navigate to a page. I works with the default setting and when I put index.php before 'postname' (like this: http://localhost/wordpress/index.php/%postname%). But this is pretty ugly and bad for SEO.
My local wordpress installation is here: /var/www/html/wordpress/, so I can reach the wordpress homepage at http://localhost/wordpress/index.php
I'm running Debian Jessie and WordPress 4.5.3
This is my htacces file automatically created by Wordpress (/var/www/html/wordpress/.htaccess). Permission are set to 664.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
The Apache Rewrite module is enabled (sudo a2enmod rewrite)
Try This :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
EDIT
In your /etc/apache2/apache2.conf change
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I have a problem with my Wordpress permalink. I tried to change permalink to postname "/%postname%/". When I test one of my page, its says that 404 Not Found.
I've looking around about my problem and tried many tutorials but no luck. In my opinion, my Wordpress access seems not working but I'm not sure because I'm newbie for this. Please anyone can help me solve this problem.
Thanks In Advance
Please check you .htaccess must look like below if not remove all code and write below:
# 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>
# END WordPress
After that run below command:
1 EDIT (Change None to all)
sudo vim /etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
To (press i to edit)
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
save (press :wq!)
sudo a2enmod rewrite
sudo service apache2 restart
Try replacing your .htaccess with default .htaccess
# 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>
# END WordPress
Make sure you backup your .htaccess before using this.
If your .htaccess file were writable, WordPress will do this automatically, but if it isn't- these are the mod_rewrite rules you should add in your .htaccess file.
1- Open .htaccess file and copy the following data in that file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
After updating the file the permalink issue will resolve.
My .htaccess file was set correct beforehand, so changing the file contents wouldn't help. On my Ubuntu server I tried:
sudo apt update
sudo apt upgrade
Afterwards it worked.
I have put my wordpress files inside a folder wordpress instead of root.
I am able to access my site as www.example.com/wordpress
But i want to access it as www.example.com, want to hide wordpress in url.
my .htaccess file is as
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
How can i do this?
Try this:
Add this to the .htaccess in your root directory:
Options FollowSymLinks
RewriteEngine On
RewriteRule (.*) wordpress/($1) [NC,L]
I have an .htaccess file for my Wordpress website with this content.
# 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>
# END WordPress
I moved this content into the Apache virtual host for my site (below) and deleted the htaccess file.
<VirtualHost *:80>
ServerName 68.183.153.223
DocumentRoot /home/david/wordpressWebSite
# 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>
# END WordPress
</VirtualHost>
However, when I attempt to restart Apache, Apache outputs an error.
RewriteBase: only valid in per-directory config files
Action 'restart' failed.
I thought that htaccess file contents could be moved to virtual hosts. What is awry?
According to the docs, RewriteBase "Sets the base URL for per-directory rewrites".
Since you're not setting up per-directory rewrites, the directive is meaningless outside of an .htaccess file for a particular directory.
RewriteBase does not work in virtualhost files.
The question you probably want to ask is:
How do I include relative paths in VHost RewriteRules?
Particularly, in vhosts, *_FILENAME returns a slash followed by the REQUEST_URI, instead of being relative or mapped to the filesystem!
Eg, %{SCRIPT_FILENAME}
In .htaccess: "assets/style.css"
In a vhost file: "/assets/style.css"
You need: "/var/www/assets/style.css"
There are several solutions:
Solution #1: %{DOCUMENT_ROOT}
RewriteRule ^/foo/bar$ %{DOCUMENT_ROOT}/foo/baz
RewriteCond %{DOCUMENT_ROOT}/%{SCRIPT_FILENAME} !-f
RewriteRule (.*) /script.cgi
Solution #2: <Directory> tags
RewriteEngine On
<Directory "/var/www/">
...
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule (.*) /script.cgi
</Directory>
Within the directory tag, *_FILENAME is treated the same as in a htaccess file.
There may be an issue using this when the server has multiple aliases.
Solution #3: %{REQUEST_URI}
Use %{_URI} instead of %{_FILENAME} where possible
Not a real answer. Just pointing out that *_URI's won't have to be rewritten as they are not supposed to map to the filesystem, and therefore vhost/htaccess paths are the same. However, it is not always possible to use REQUEST_URI, and David Faux commented above that it is slower. Besides, thi