htaccess issue with multiple wordpress installed in root and subdirectory - php

I have installed 2 wordpress site in one host. Originally I have installed it in root folder, for some reason I need to install another wordpress site separately in a subfolder which later on I will going to link it in a subdomain. While I have sucessfully Installed the new wordpress, however I have an issue with my htacccess.
Here is my htaccess in my root
# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php
# 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
and here is my htaccess in the subfolder
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /help
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /help/index.php [L]
</IfModule>
# END WordPress

Change
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /help
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /help/index.php [L]
</IfModule>
# END WordPress
To
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /help
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Related

.htaccess for public folder as root and sub folder for subdirectory

I'm currently trying to achieve this using .htaccess
http://example.com - using public_html folder
http://example.com/places - using the places folder
This is the current structure of my folders and also both public_html and places folder are a wordpress site
root
|-public_html
|-places
| |-.htaccess
|-.htaccess
root/.htaccess
RewriteEngine on
RewriteCond ${HTTP_HOST} ^example.com$ [NC,OR]
RewriteCond ${HTTP_HOST} ^www.example.com$
RewriteCond ${REQUEST_URI} !public_html/
RewriteRule (.*) /public_html/$1 [L]
# This is a must
# 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
root/places/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /places/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /places/index.php [L]
</IfModule>
# END WordPress

Wordpress error 404 to access custom subfolder in current template foler

My wordpress blog is installed in a subfoler : /wp/. I have create a subfolder in in the directory of the theme used : /test/
But when I try to access by the url : http//www.domain.com/wp/test/. I have an error 404
My .htaccess in wordpress root directory:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteCond %{REQUEST_URI} ^/test/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
# END WordPress
# 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
</IfModule>
# END WordPress
My .htaccess in \test\ folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
</IfModule>
ry replacing your rule with this:
RewriteRule ^test(/|$) - [L,NC]

Access Standalone PHP File With Wordpress Installed

I have just installed wordpress on a site. However, I have some standalone php files that I use for analyzing database data on the site that now return a 404 when trying to access them.
For example:
www.mywordpresssite.com/myscripts/myscript.php
This returns a 404.
Here is my .htaccess:
# 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>
Is there any way I can achieve normal access to the said directory/file but without upsetting the current functionality of Wordpress?
Thanks a lot
Change your .htaccess file to this
# 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>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/myscripts/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>

How do I remove the extension for an external file in my wordpress htaccess file?

At the moment I have the following in my wordpress .htaccess file:
# 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've uploaded a separate .php file called contact.php that I'd like to rewrite so that users can access it via http://mydomain.com/contact instead of http://mydomain.com/contact.php
What do I need to put into my .htaccess file so that I can have this rewrite for this one file only?
Just add one line for your redirect as shown below:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^contact$ /contact.php [L] <-- New Line
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
You should put this before the # BEGIN WordPress comment, since it's not WP related:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^contact$ /contact.php [L] # /contact rewrite
</IfModule>
# 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

Wordpress setup for WAMP local environment

I have downloaded a word press site I need to work on the front-end. The problem I am having it that every page apart from the homepage displays my root server /index.php
Since downloading I have:
Updated the wp_options for both siteurl and home
Updated the rewritebase in .htaccess url to the name of the subfolder.
Is there anything else I need to update?
The admin area fully works correctly just every page/post apart from homepage
EDIT: Add .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
END2 - Fixed by removing a /
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress

Categories