Struggling with friendly urls in wordpress - wordpress

I edited the permalink settings by changing the custom structure to:
/%postname%/
Now, when I click on a page link it'll take me to domain.com/postname, but I get a 404 error. Doing some digging this shows that I need to setup 301 redirects, but I'm confused as to how to do this. I've edited my .htaccess file - it now looks like:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mgassoc/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mgassoc/index.php [L]
</IfModule>
# END WordPress
Can anyone help me with what I'm doing wrong?

Try doing this and see if it helps.
Add the following into your httpd.conf and re-start apache.
<Directory "/path/to/your/app">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Related

Wordpress/htaccess - allow access to subdirectory

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.

Wordpress: Page not found - Permalink postname

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>

Adding new lines to .htaccess breaks the whole site

I have an issue that when I add a simple line to the .htaccess file it immediately gives me an internal server error. I have no idead what is wrong, the current content of the .htaccess file is the following:
# 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
If I add a line and get the .htaccess file looking like below, it immediately breaks the site and gives me 500 Internal server error:
# 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
#Begin security
<files wp-config.php>
order allow,deny
deny from all
</files>
Could you kindly let me know what I can check in order to stop this from happening?
Another thing which I also noticed is that if I add a security plugin through wordpress, and start enabling things, it also breaks the site.
I have also looked in the error log when trying to load the site and the following is the error I get:
.htaccess: order not allowed here
I have fixed the issue, what I noticed is that the following configuration in my directory was blocking the .htaccess to work
AllowOverride FileInfo Options
Changed it to the following and everything
AllowOverride All

Wordpress (Postname Permalink) 404 error

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.

Install WordPress in its own directory but permalink fails

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

Resources