I’m creating blog page as WordPress for my static PHP website. When blog page URL changes to pretty permalink
(example.com/blog/my-post-page
), loading contents (not redirecting to index.php, only contents loading and URL will be like http://example.com/blog/my-post-page) of index.php
(home page for my site) that is located outside blog folder instead of single.php
contents.
When permalink changes to default
(example.com/blog/?p=123
), it will work perfectly.
I need URL as http://example.com/blog/my-post-page.
EDIT : – I have updated permalink to Custom Structure as /index.php/%postname%/
. But now post pages are showing with example.com/blog/index.php/my-post-page
.
I think the issue raised with the new WordPress version. (Version 4.2.2).
Any solutions to remove index.php
from URL ?
My Directory Structure:-
/ - Root
/blog - Blog folder
/blog/wp-content/themes/mytheme/ - Theme folder
/blog/wp-content/themes/mytheme/single.php - Post Single page
/index.php - Home page (Loading contents of this file)
My htaccess :-
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
When I delete/rename index.php in root folder, page will show not found error.
in
htaccess
you can write any regex expression for url rewritein your case
this line means that if url starts with
/blog/
anything after/
would be passed to/blog/index.php
aspostname
parameter.example.com/blog/my-post-page
would be rewritten asexample.com/blog/index.php?postname=my-post-page
you can exclude anything from this rule
for example let’s exclude this:
/blog/wp-content/themes/mytheme/
it would go like this:
It should work
You need to make two changes here, change
permalink
to/%postname%/
.and change .htaccess to following