Configuring WordPress .htaccess to view subfolders - wordpress

I have a WordPress installation with an .htaccess file that looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I tried installing a fresh copy of WordPress into a subdirectory for a separate blog and am getting 404 errors within the root WordPress when I try to view it. I'm assuming this is because of the .htaccess file.
How do I change it so that I can view the subfolder?

For future reference, you may want to try this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog2/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog2/index.php [L]
</IfModule>
# END WordPress

Edit#2: ok i think i figured this out, but it's pretty messy.
modify your base wordpress install's .htaccess file to look like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/blog2/.*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
now, load a new copy of wordpress into "blog2/", and copy your wp-config.php file over to it. edit the "/blog2/wp-config.php" file and change the $table_prefix to something different than your first blog. (this will install both wordpresses into the same database).
once you've done that, you should be able to go to:
http://yourdomain.com/blog2/
and finish up the installation without issue. the initial problem was that the new copy of wordpress kept trying to use the first copy's wp-config.php file. moving it over manually fixed that all up.
because i'm insane, i tested this with two fresh copies, wrote a few test articles, and was able to navigate around without issue, so it should work :)

Related

WordPress Broken Images

I don't know what can cause this problem, but my WordPress web-site after migrating to new server is not showing me images. It is maybe something in .htaccess file, rewrite rule or something. Any directions please?
Please click here to see my page.
.htaccess from public_html directory:
# 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
.htaccess file from wp-content/uploads:
# BEGIN alti-watermark Plugin
<ifModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*(-([1-3][\d]{1,2}|[\d]{1,2})x300|-300x([1-3][\d]{1,2}|[\d]{1,2})|-([1-1][\d]{1,3}|[\d]{1,3})x1024|-1024x([1-1][\d]{1,3}|[\d]{1,3})|-940x446)\.jpg|.*(?<!-\dx\d)(?<!-\d\dx\d)(?<!-\dx\d\d)(?<!-\d\dx\d\d)(?<!-\d\d\dx\d\d)(?<!-\d\dx\d\d\d)(?<!-\d\d\dx\d\d\d)(?<!-\d\d\d\dx\d\d\d)(?<!-\d\d\d\dx\d\d)(?<!-\d\d\dx\d\d\d\d)(?<!-\d\d\d\dx\d\d\d\d)(?<!-\d\d\d\dx\d\d\d)(?<!-\d\d\d\dx\d\d)(?<!-\d\d\d\d\dx\d\d\d\d\d)\.jpg){1}((\?|\&)([^\.\?\ ]+))*$ ../plugins/alti-watermark/public/views/alti-watermark-public-bridge.php?imageRequested=$1 [PT]
</ifModule>
# [date=2016-12-27 18:06.57] [php=5.4.45] [width=300x300|1024x1024|940x446|fullsize] [plugin_name=alti-watermark] [version=0.3]
# END alti-watermark Plugin
Thanks in advance!
Usually that's because file paths are saved as absolute paths in the database.
In this case you either need to get some plugin that changes all those filepaths for you (see https://wordpress.org/plugins/search/migration/ for resources) or export your database as a mysql file, open it in an editor and do a search/replace to replace all old filepath instances with the new one, and then import that again in your database.

Can't access 2nd Wordpress instance in subdirectory

I've installed a second instance of wordpress in a subdirectory but when I try to access mysite.com/newsite I get a 404 error page on the root wordpress install page/theme. I've looked at the .htaccess files which have rewrite rules, tried adding an exception for the /newsite folder in the root .htaccess but it had no effect.
Can someone help with this?
Did you try this set of instructions? According to that site, the .htaccess in the second installation should look like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /newsite/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /newsite/index.php [L]
</IfModule>
# END WordPress
Try that out if you haven't and let me know if it works.

Wordpress Permalink Custom Url /index.php/%postname is working while /%postname is not working

I have uploaded my website to the server and when i am trying to change permalink, it is working only with /index.php/%postname.
Neither /index.php/%postname/% is working nor /%postname/* is working.
Thanks in advance....
put below code in .htaccess file in wordpress site directory. verify similar code is already present in .htaccess file or not. If present please replace with below code. if no .htaccess file is present please create one with following code.
# 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

Some WordPress permalink problems, probably depending by wrong .htaccess configuration?

I have import on my local webserver a backup of a website made using WordPress but I am finding some difficulties with PermaLink configuration
The main problem is that if I use the permalink setted as Article Name I can see the homepage but if I click on the articles links into the homepage (to see the article) I always obtain the following message error:
Not Found
The requested URL
/wordpress35/2012/10/11/se-milano-avesse-il-mare-anzi-no-la-montagna-di-campiglio/
was not found on this server.
If I instead I use the Default settings for permalink (http://localhost/wordpress35/?p=123) I have no problem and I can access to the articles in my website
I think that this is a .htaccess problem. Can you help me to create an .htaccess file that solve this problem?
My actual .htaccess file is:
# 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
I need to use the URL format described as: http://localhost/wordpress35/my-article-name
Did you try creating a the wordpress .htaccess for your needs?
# 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
This should work if you didn't specify any change in the website's URL.
(If the homepage is still http://localhost/wordpress35/ )

Wordpress Intalled on a separate directory and .htaccess redirection

I've installed my wordpress site on a separate directory and followed all the steps described here and now I can access my site from my main domain. So, my Wordpress site is installed under: www.mysite.com/wp-site/ and now I can access my site under www.mysite.com, so all is great, exactly what I wanted. Wordpress is making this happen through an .htaccess file it creates that has the necessary code to make the redirection happen (SEE CODE BELOW).
My problem is that I have other directories on my site, such as www.mysite.com/another-directory-unrelated-to-wordpress/ that I cannot access anymore because I believe wordpress and the .htaccess file it created is redirecting everything to the root.
How can I avoid Wordpress from redirecting all my other subfolders and files? Thanks a ton for any ideas or help.
Here is the htaccess file code:
# 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 way the WordPress .htaccess file works is if an existing file or directory is requested, it does not send the request through WordPress...that's what the !-f and !-d RewriteCond statements do.
So, there is something else going on with your site. Have you used Firebug or any other debugging tool to see what is happening with the request/response?
You could always enable mod_rewrite logging to see if that gives you a clue.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteLog "rewrite.log"
RewriteLogLevel 3
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
A RewriteLogLevel of 5 would give you the most information. Make sure to comment out or remove the RewriteLog* lines when you have figured out the issue.
UPDATE: Check this other SO answer to see if it resolves your issue

Resources