Wordpress permalinks with files and folders out site of Wordpress - 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.

Related

Wordpress blogpost subdirectory

I have a blog subdirectory
public_html/blog
the site can be accessed like this
https://example.com/blog
by default, the blogposts are accessed like this
https://example.com/blog/index.php/hello-world
I want to remove the index.php and access the posts like this
https://example.com/blog/hello-world
I have this .htaccess file from where i looked into how to install a wordpress subdirectory
<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>
https://www.wpbeginner.com/wp-tutorials/how-to-install-wordpress-in-a-subdirectory-step-by-step/
However when I tried to change it via
Settings -> Permalinks -> Common Settings -> Post name
I end up with a 404 from the main wordpress installation. I have a faint idea that this might be an issue with the htaccess? But i don't really get how to fix it.
when I remove the index.php with the settings it gets redirected to the 404 of the main wordpress installation
That's because the rewriting for that main WordPress installation rewrites everything that does not match a physically existing file or folder, to its own index.php. (Which then goes and looks up the requested URL in its database, doesn't find any matching content, and responds with a 404.)
/blog/index.php/hello-world matches the existing index.php in that folder (the rest is considered PATH_INFO), so the rewriting of the main WP leaves it alone.
But /blog/hello-world does not match anything that exists in the file system.
So you need to exclude any paths starting with /blog/ from the rewriting inside your main WP installation.
https://stackoverflow.com/a/15297697/1427878 shows the basic way to do that, although there the content between the # BEGIN WordPress/ # END WordPress comments gets modified (which one should not do, because that part will be overwritten when the permalink settings get flushed in the backend.)
Better to do it outside of those. Try and put this at the very top of your .htaccess of the main WP installation:
RewriteEngine On
RewriteRule ^blog/ - [L]
For any path that starts with /blog/ (leading slash has already been removed from the relative path that RewriteRule matches against), simply do no rewriting at all, and make this the last rule to be processed at the same time.

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.

wordpress permanent link htaccess issue

My WordPress site has permanent link issues - .htaccess
In the WordPress Permanent link section,
1) When I select the post name URL (www.myworld.org/sample-post/) it's not working. Actually it's throwing the 404 error whenever linked to sub pages of the web site.
eg: www.myworld.org/aboutus/
2) When I place the custom link with %index.php% it works fine (www.myworld.org/index.php/%postname%/). However all the sub pages URL coming with index.php
eg: www.myworld.org/index.php/aboutus/
I want to get rid of the index.php in all the sub pages URL.
3) Actually my website files are placed into one separate folder on the root.
eg: /newsite/... (all WordPress files wp-content, wp-include, wp-admin etc.)
Also I've placed .htaccess file inside /newsite/ directory along with other WordPress files.
eg: /newsite/.htaccess
My .htaccess file below:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./index.php [L]
</IfModule>
Even I've .htaccess file However I've 404 page issue when change the permanent link to postname.
eg: www.myworld.org/sample-post/
Try to change URL structure from Post Name to Plain and refresh your website ... once you have done check you front end page if it shows proper URLs, After doing this, revert back your Permalinks to Post Name ... hope that will fix your issue ... your .htaccess file is looking standard one at the moment.

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 - 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?

Resources