Wordpress - Subdirectory - htaccess - wordpress

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?

Related

Magento and Wordpress with Fishpig extension giving 404 when moved to localhost

I had the Fishpig extension installed on a live magento site with wordpress blog all working fine. Wordpress is installed in magento/wp/ and is displaying as magento/blog/
I wanted to move the site to test server to develop offline. I moved the database and files, using mamp and updated:
magento db web/secure/base_url and web/unsecure/base_url
/app/etc/local.xml with db details
wp_options change siteurl and home
The homepage of magento is loading, but /admin/ is just giving a 404. The /wp/ is loading but just the site title is displayed, not the content or the magento theme. The wordpress admin is working, but /blog/ is giving a 404.
Ive read other related threads. I think all files have correct permissions and databases must be connecting. I'm thinking this must be down to fishpig, are there some setting for that i need to change, or maybe the .htaccess is messing things up?
I dont seem to have anything in var/log
I was looking throught the .htaccess file in the root of my local site and found this block
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
</IfModule>
# END WordPress
I commented it out and everything started working. Its the block that is in the /wp/ directory .htaccess file. I have no idea how it found its was into the root file - but this seems to have been the problem.

Setting .htaccess for Wordpress in a subdirectory with 'Post name' permalinks

I am trying to set up a Wordpress installation, where Wordpress is in a subdirectory, but where the subdirectory is always rewritten out of the URL.
I've been trying to follow a whole bunch of other questions / posts about doing this, but no one else's solutions seem to work for me, and a lot of the time they just get the pages to load, without removing the subdirectory from the URL, which is crucial for me.
I'm also hoping for a solution that will work the same locally (http://localhost/wordpress) as it will on a live server (http://example-site.com). However, I'll explain the problem from a local point of view:
My root folder is structured like this:
.htaccess
wp /* contains all wordpress core files */
wp-content /* custom wp-content folder, which is set to be pointed at in my wp-config */
wp-config.php
So, if we ignore the .htaccess, the site would be accessed by going to http://localhost/wordpress/wp, and the goal is to access it by just going to http://localhost/wordpress.
This was achieved using this .htaccess:
RedirectMatch 302 /wp/$ /wordpress/$1
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ wp/$1
RewriteRule ^(/)?$ wp/index.php [L]
</IfModule>
However, at this point, my wordpress installation was set to use default permalinks, which create pages like http://localhost/wordpress?p=12. I need to set this to a different permalink type, which uses URL segments rather than query parameters, like http://localhost/wordpress/hello-world. Once that setting is changed, I can no longer access other pages with that .htaccess (the home page still works fine though)
I tried using this .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ -
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/wp/$1 [L]
</IfModule>
Which now causes the sub pages to load, though the home page no longer does, nor do some asset files, like http://localhost/wordpress/wp-includes/css/admin-bar.min.css
I can't seem to find a solution that makes everything work at the same time!
I'd also like to mention that I have a very small understanding of writing .htaccess files, so if anyone is going to answer this, please explain things like I am an idiot, as I may not understand you otherwise.
I am considering that you have redirected the domain to the relavant folder, or on shared hosting you have setup the domain to point to your subfolder. I am also considering that you are adding the htaccess to the root. Here is code from the official codex for your situation.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?YourDomain.com$
RewriteRule ^(/)?$ blog [L]
Replace yourdomain.com and blog with website address and directory. Delete everything else from the file. Then goto settings > permalink and change the permalink to what ever you want.

Multiple wordpress sites at one host

I have problems with one of my Wordpress sites at my host.
Today I installed "Traffic Stats Widget" - plugin and I followed their instructions for installation. So , I did this:
Create a robots.php file on the root directory of your blog: ie public_html/your-blog/ Paste the following code without // in it:
# #
Open .htaccess file in the same directory and paste this in it:
RewriteRule robots.txt robots.php
Make sure you have the 'RewriteEngine On' clause in place...
Make sure you have a robots.txt file, even an empty one, on the root directory
After that I was unable to access all of my subpages.
This is link of my website:
http://idealpvc-dev.com/websites/camel/
And if you try to access some of subpages you will get error 404.
I don't know why, because I restored my .htaccess file but still it doesn't work.
Also I made comparison with others .htaccess file on other wordpress sites but there isn't any differences except folder names.
Any suggestion will be appreciated.
Also, above is content of my .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /websites/camel/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /websites/camel/index.php [L]
</IfModule>
# END WordPress
Sites is located at /public_html/websites/camel
Thanks in advance
Make this as a RewrieBase in your htaccess file
RewriteBase http://idealpvc-dev.com/websites/camel/
Instead of this
RewriteBase /websites/camel/
And make your wordpress permalink Default From Wordpress Admin panel > Settings >> Permalink >>> Default

Wordpress permalinks with files and folders out site of Wordpress

I have a wordpress site and I also have pages/files/folders that I've created outsite of wordpress. Right now, I have no permalinks with my URLs as site.com?p=123. I want to have permalinks (pretty links) as site.com/postname (I know the permalink string is /%postname%/). I also have pages that are on my site that have nothing to do with the wordpress site.
When I changed the permalinks in wordpress, all my posts work fine just like they should. But when I try going to an outsite wordpress page/folder like site.com/file_name.php or site.com/folder_name/ I get HTTP 404 not found.
Is there a way that I can do this, or am I stuck with having just the post id permalink?
The default WordPress .htaccess configuration for permalinks should handle files that exist on the file system outside of WordPress. You can read about using permalinks in the Using Permalinks documentation on WordPress.
Of note is the snippet that you're supposed to include in .htaccess (so maybe update your .htaccess file to contain this content):
# 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
The RewriteCond clauses tell WordPress that if the current URL either points directly to a file or to a directory, then WordPress will ignore it and let the file load normally.
Open up the Wordpress .htaccess file after enabling SEO permalinks and add the following line on top:
ErrorDocument 401 default
Let me know if that works, or you can always explicitly allow those specific files/folders in the .htaccess file.

WordPress sub domain htaccess issue

Well I did a wordpress installation with the newer version now available at dere website..
I did my installation at a subdomain: foo.abc.com
the problem came with the permalink which do not work dere bec of the htaccess file.
Can any one suggest me how to do that, i need to have only the category/postname
Till now i am able to do foo.abc.com/index.php/category/postname - I don't want index.php in it.
I have used this htacess file:
# disable the rewrite engine
RewriteEngine on
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
RewriteRule ^post/([0-9]+)?/?([0-9]+)?/?$ /index.php?p=$1&page=$2 [QSA]
</IfModule>
# END WordPress
Please correct me if possible.
I'm not totally sure I understand the problem, but I'll try and throw out a few solutions.
In the Wordpress back-end, under the General Settings Tab- have you set the "Blog address (URL)" and "WordPress address (URL)" to the correct domain? This may write the correct .htaccess setting for you.
If you are trying to do something fancier with the domain such as category.blog.com/post_id, perhaps take a look at the WP Subdomains plugin.

Resources