Why permalinks work with index.php%postname% but not with just %postname%?

I'm having a problem with Wordpress permalinks. I change the permalinks to pretty permalinks but I am just getting

I'm having a problem with Wordpress permalinks. I change the permalinks to pretty permalinks but I am just getting 404s for the pages now. The strange thing is when I use /index.php/%postname% the page links work fine, but I need to get rid of the index.php part.

I read about making changes to httpd.conf file but can't find the file anywhere. The htaccess file is correct as far as I can find out, it's 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

Any other ideas?

Thanks Emma

I'm having a problem with Wordpress permalinks. I change the permalinks to pretty permalinks but I am just getting 404s for the pages now. The strange thing is when I use /index.php/%postname% the page links work fine, but I need to get rid of the index.php part.

I read about making changes to httpd.conf file but can't find the file anywhere. The htaccess file is correct as far as I can find out, it's 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

Any other ideas?

Thanks Emma

Share Improve this question edited Jul 12, 2011 at 11:40 Bainternet 67.7k8 gold badges132 silver badges188 bronze badges asked Jul 12, 2011 at 11:33 emmahiggyemmahiggy 711 gold badge1 silver badge2 bronze badges 9
  • whats your host? – Bainternet Commented Jul 12, 2011 at 11:41
  • Hey, it's a local company, running a server from their shop. They have a very basic web panel! – emmahiggy Commented Jul 12, 2011 at 12:20
  • Maybe check the .htaccess file permissions. Maybe WP can't get to it? – Cristian Commented Jul 12, 2011 at 12:38
  • I have the file permissions for the htaccess file set to 644, the permalink is changing but the pages are not changing with it so I'm getting 404s when the permalink is correct. – emmahiggy Commented Jul 12, 2011 at 14:28
  • What's the exact value of the permalinks setting? – Alex Older Commented Jul 12, 2011 at 14:39
 |  Show 4 more comments

13 Answers 13

Reset to default 12

I had all the correct code in the .htaccess file, but it ended up being completely overridden in the Ubuntu default /etc/apache2/apache2.conf file as well. Changed the entry for / and /var/www from AllowOverride None to AllowOverride All, restarted Apache and now everything works just fine.

My guess is that mod_rewrite is not enabled. Depending on what server you are using, enable mod_rewrite.

Then, if you are on Linux, manually edit /etc/apache2/sites-enabled/000-default and change AllowOverride for from None to All (or where your site's directory is).

Here, at points 3 & 4 should be solutions for Windows.

I've been working on similar problem since yesterday and finally found my solution.

1) Ensure your .htaccess has permission of 666

2) Enable the mod_rewrite:

sudo a2enmod rewrite

3) restart apache:

sudo systemctl restart apache2

4) AllowOverride All for the public directory on /etc/apache2/apache2.conf

<Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

5) Restart apache:

sudo systemctl restart apache2

6) Go to Wordpress dashboard and change the permalink settings (if you are on postname, change to plain, or vice versa). View the site to check.

7) Go to dashboard again and change permalink settings to your desired settings.

8) Revert .htaccess settings to 644

This worked for me.

Are you by any chance using Names.co.uk as your host?

I just had the same problem as you, and after a couple of hours of Googling I found out that they use a Zeus server - not Apache - and it does not support the Mod_ReWrite function. This seems to account for the confusing symptoms. (I had no .htaccess file - but no errors reported from Wordpress whenever I made a change to my permalink preferences.)

They have a workaround for Zeus, detailed here:

http://www.names.co.uk/support/hosting/linux_hosting/1119-wordpress_rewrite_script.html

I realise this is a couple of months after your original post and you've probably solved it by now - but for anyone who finds this in the future it would be a good idea to check if your host uses Zeus or some other non-Apache server.

Update: Please see the code I posted here on a similar question

I have been battling this issue for a while, and today I resolved this problem. I found out that my mod_rewrite wasn't enabled all this while. I found the information on this link very useful. It explains everything from how to check if the mod_rewrite is enabled, and if not - how to enable it. I hope this information is useful for anybody who is new to WP and struggling with setting pretty permalinks.

Try setting the htaccess to 777 then go in and update the permalink settings to what you want, then if it works go back and change it back to 644

After adding my content I found an article that suggested deleting the .htaccess file, then go to Settings/permalinks and remove the index.php. The article said WorPress would give an error suggesting you create the .htaccess file. I decided to try it but it did nothing. What I did find out is my permalinks were still working with the deleted .htaccess file. This puzzled me at first. I opened my FTP client and navigated to my files. I noticed that there was a .htaccess file there after I had deleted it. I don't know if it is WordPress, my Hosting Account or what exactly created it but I know this is new. This didn't happen before. You might try this method if all else fails.

I wasn't able to re-create the problem in your question so I'm not 100% sure if it works for you. It's worth a shot though.

regards, Jeremy Jared

Try replacing the .htaccess code with this:

# -------------------------------------------------------------------------
# Rewrite Engine options
# -------------------------------------------------------------------------

RewriteEngine On
RewriteCompatibility2 On
RepeatLimit 200
RewriteBase
RewriteRule ^/index.php$ / [NC,P,R=301]
RewriteCond %{REQUEST_URI} !/wp-admin
RewriteRule ^/(.*)/$ /index.php/$1 [NC]

# Redirect 'www.yourblogsite/anything/anything/index.php'
# to 'www.yourblogsite/anything/anything/'

RewriteRule ^/(.*)/index.php$ /$1/ [NC,P,R=301]

# -------------------------------------------------------------------------
# END REWRITES
# -------------------------------------------------------------------------

I still had the log-in credentials to a client I had to fix this for. This is what I used for him. It is an IIS Server, I'm not sure if that matters but you can try it. Good Luck, JJ

I know its too late to reply now but if you are still looking for this; here is a quick way to that:

Solved- How To Remove Index.php From WordPress URL On IIS7?

I was having this issue on Mac OSX and the following was very much useful. It seems that by default Mac's are not .htaccess ready by default and Apache will ignore the file until certain files (specified on the links below) are modified:

http://wordpress/support/topic/getting-pretty-permalinks-working-on-a-mac-105-server

http://clagnut/blog/350/

Hope that helps!

This is for apache server : Hi First Check your vitual host if you are using default, check wordpress root directory has this

  <Directory ROOT_DIR_FOR_WORDPRESS>
            php_admin_flag engine on
            AllowOverride All
            Order allow,deny
            allow from all
            RewriteEngine On
            RewriteOptions Inherit
            Require all granted
    </Directory>

check your .htaccess file in wordpress root has permission to read,write (666) and contains

# 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

Enable mod rewrite (sudo a2enmod rewrite - for linux users)

Now update the permalink custom structure : /%postname%/

save and check for any errors Now it should be working

Most of the time issue is , your .htaccess is overridden by your virtual host rules

You need to do sudo a2enmod rewrite to enable module rewrite

I think your host uses IIS (Internet Information Services). IIS uses "URL Rewrite" not "mod_rewrite", so take a look at the Codex.

"Pretty" permalinks usually require mod_rewrite, and IIS (common on Windows servers) does not support mod_rewrite. (If you are using Apache 2.0.54, on Windows, mod_rewrite may work, provided it is enabled in apache\conf\httpd.conf.)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744947215a4602694.html

相关推荐

  • Why permalinks work with index.php%postname% but not with just %postname%?

    I'm having a problem with Wordpress permalinks. I change the permalinks to pretty permalinks but I am just getting

    2天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信