简体   繁体   中英

Wordpress - Subdirectory - htaccess

I have Wordpress installed in a subdirectory:

/public_html/blog/

I want to be able to access the blog like this:

http://example.com/blog

and posts like this:

http://example.com/blog/category/postname

In general settings I have the "WordPress Address (URL)" set to:

http://example.com/blog

Permalinks is set like:

/blog/%category%/%postname%

In the subdirectory (/public_html/blog/) I have an .htaccess like:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

Everything works EXCEPT for being able to access the blog Home page at: http://www.example.com/blog Doing that sends me to the "Wordpress 404 page not found" page.

I'd be very grateful for a solution!

EDIT

I'm an idiot - I missed something vital. I needed to also change the Site URL in Wordpress > General to:

http://example.com/blog

Doing that and then removing /blog/ from the permalink structure made everything work. I probably wouldn't have spotted this if @IanB hadn't picked up the /blog/ bit not being necessary. Thanks...

2 things come to mind. I don't think you need to add /blog/ in your permalink structure, (unless wordpress is adding that for you). That should be automatic if that is the file it is installed in.

Also, Where is your index.php file for your wordpress install - Is it in the blog folder or in the /public_html/ folder.

If you want to display the blog at http://example.com/blog it should be in the blog folder.

What is the filepath you use to log in? Does that work fine?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM