wordpress - Loading index.php contents which located outside blog folder for post single page -


i'm creating blog page wordpress static php website. when blog page url changes pretty permalink (example.com/blog/my-post-page), loading contents (not redirecting index.php, contents loading , url http://example.com/blog/my-post-page) of index.php (home page site) located outside blog folder instead of single.php contents.

when permalink changes default (example.com/blog/?p=123), work perfectly.

i need url http://example.com/blog/my-post-page.

edit : - have updated permalink custom structure /index.php/%postname%/. post pages showing example.com/blog/index.php/my-post-page.

i think issue raised new wordpress version. (version 4.2.2). solutions remove index.php 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 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 delete/rename index.php in root folder, page show not found error.

in htaccess can write regex expression url rewrite in case

rewriterule ^/blog/\(.+)$ /blog/index.php?postname=$1 

this line means if url starts /blog/ after / passed /blog/index.php postname parameter. example.com/blog/my-post-page rewritten example.com/blog/index.php?postname=my-post-page

you can exclude rule

for example let's exclude this: /blog/wp-content/themes/mytheme/ go this:

rewriterule ^(?!/(.+)/(.+)/(.+)/(.+))/blog/\(.+)$ /blog/index.php?postname=$1 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -