Accessing Another Directory with Wordpress Installed - wordpress

I have Wordpress installed on a shared host at Site5. It's installed in the root directory:
www.domain.com
I have another directory that I want to be able to access outside of the Wordpress site:
www.domain.com/directory/
When I visit this URL, I get Wordpress's 404-page. The .htaccess file, as modified by WP, reads:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I assume I need an edit to the .htaccess file to access this directory?

Edit .htaccess present inside "directory"
It should be:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /directory/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /directory/index.php [L]
</IfModule>

Related

How to access folder that is in root (WordPress)

I have created a folder in the root of my server. While trying to access it from a URL it gives a 404 error.
How can I create a .htaccess to access this folder and file inside the folder?
Try this .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Want to stop subdirectory from showing in urls

I've read a lot of threads on this topic, but I'm not very proficient at this stuff and nothing has worked for me.
I installed Wordpress in a sub directory and:
Changed the site address URL to the main domain in WordPress.
Then I copied the .htaccess and index.php to the root directory.
Then I changed the index.php file so that the require(‘wp/wp-blog-header.php’) pointed to the subdirectory.
Everything works, except the subdirectory shows in the URL, which I would like to hide.
The subdirectory I installed to is 'NA20H'. After changing the index.php file to point to it, this is what I have.
The .htaccess file in the Root directory reads:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /NA20H/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /NA20H/index.php [L]
</IfModule>
And the .htaccess in the subdirectory reads:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /NA20H/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /NA20H/index.php [L]
</IfModule>
What do I need to do in order to get 'NA20H' to stop showing in the URLs?
Thank you.
No need to copy index.php to root. Just follow these steps.
Put this in the .htaccess in the root.
RewriteEngine On
RewriteBase /
RewriteRule ^$ NA20H/ [L]
RewriteRule ^(.*)$ NA20H/$1 [L]
Put this in .htaccess in the NA20H folder
RewriteEngine On
RewriteBase /NA20H/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

How to clean url wordpress

I'm using wordpress for a site,
this url before tes.com/index.php/about/
i want url like this tes.com/about/
I have tried copying parts of WordPress' .htaccess, however shows a 404 error.
My .htaccess file looks like:
# 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
Any ideas on where to start and how to accomplish what I'm looking for?
Go to your WP-ADMIN-->Settings-->Permalink and use the permalink structure change there, if it generate any .htaccess file copy the content and update your .htaccess file.
Or Check if your hosting mod_rewrite is enable by creating a file phpinfo.php with content,
Upload this file and browse via Browser. So you know which modules are enabled. You need mod_rewrite enable to remove index.php from URL.
Try this -
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test.com/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test.com/index.php [L]
</IfModule>
The official instructions will give you clean urls. So best to follow this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Redirect directory (but not subdirectories) to another directory

How do I redirect a directory to the root of a site? Provided that:
the root of the site is actually not the root of the domain. ex: it should redirect to 'www.example.com/website', not to 'www.example.com'
don't redirect subfolders. ex: it should redirect 'www.example.com/website/portfolio' to 'www.example.com/website', but it shouldn't redirect 'www.example.com/website/portfolio/project-name'.
It's a WordPress site and it's already working with the following rules:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /website/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /website/index.php [L]
</IfModule>
# END WordPress
Thanks in advance!
You can do:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /website/
RewriteRule ^portfolio/?$ /website/ [L,R]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /website/index.php [L]
</IfModule>

Unable to ignore a directory in WordPress install via .htaccess

/custom/player-registration.php
I've used the following .htaccess in my WordPress install and I can't access the above URL... any tips? I've tried 2 methods here... The URL continues to go to a WordPress search page.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^custom - [L,NC]
RewriteCond %{REQUEST_URI} !^/(custom|custom/.*)$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
UPDATE
I suppose I need to clarify that I am able to access /custom but am NOT able to access files within that directory... how do I access files within that directory?
Default WP .htaccess:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
means: if request doesn't point to any existing file or directory, use index.php
So it should serve Your file well with default settings. What are You trying to acomplish with the rest of Your file?
Try
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^custom.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Resources