I have Wordpress installed in root and a particular folder not related to Wordpress. I created a .htaccess file for the particular folder, but it is not working. The Wordpress .htaccess is always been called.
Wordpress .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>
# END WordPress
Particular folder .htaccess:
//301 Redirect Old File
Redirect 301 http://www.domain.com/folder/start.php http://www.domain.com/folder/index.php
When I load the above old address (that does not exists), the Wordpress .htaccess is called, instead of use the folder's .htaccess to redirect.
You don't need multiple .htaccess you can put all the rules on the WordPress main .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !^folder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Use either:
RewriteRule ^folder/start\.php$ /folder/index.php [R=301,L,NC]
Or
Redirect 301 /folder/start.php http://www.domain.com/folder/index.php
Don't forget to change folder to your actual folder name.
Related
I have a problem on my WordPress multisite. There's a WordPress installation on the root folder (public_html) of my domain and it was working fine.
We had to install a second WordPress site in a subfolder (public_html/subfolder).
If I try to access example.com/subfolder, the second website works fine.
If I try to access example.com, it redirects to example.com/subfolder. I no longer can access the first website.
ROOT .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>
# END WordPress
SUBFOLDER .HTACCESS
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subfolder/index.php [L]
</IfModule>
# END WordPress
Can someone explain how to prevent this redirect?
Thanks!
Try to delete (or rename) root .htacces.
I have the following stucture:
Wordpress installed in root, and an /api/api.php file manually created
When I go to www.example.com/api/api.php I get a 404
This is my .htaccess in the root folder:
Options +FollowSymLinks
RewriteRule ^api/api\.php$ - [L]
# 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 expect this should have let requests to /api/api.php through unmolested.
Also, I tried putting in a .htaccess file in /api with just
# disable the rewrite engine
RewriteEngine off
but I am still getting a 404 error despite this.
The rest of the site works fine, and I have tried disabling all WP plugins just in case.
try change your permalink from admin panel or if you have an IIS7 server then your permalink should be like %postname%index.php.
and also try this .htaccess code and instead of 'example' write your site base path name
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /example/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /example/index.php [L]
I am using GoDaddy Delux Hosting, Linux server. I have a wordpress installation in the root directory. I've started a development directory under the root directory. I don't have a wordpress installation under the development directory, but my own project.
My objective is to circumvent wordpress url rewriting just for the development directory, and redirect every url that starts with the development directory to development/index.php. I have experimented with numerous mod_rewrite combinations, but I couldn't get it work. I get the standard wordpress "page not found" page for everything except mysite.com/development/index.php
The last configuration I've come up with is the following:
root directory .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(development|development/.*)$
RewriteRule . /index.php [L]
</IfModule>
development directory .htaccess file:
RewriteEngine On
RewriteRule .* index.php [L]
Any ideas how to best approach this?
PS: I haven't used "development" in Wordpress as a slug.
In the main .htaccess file you should ignore anything under "development" - you don't need the initial forward slash because of RewriteBase / and you can make the trailing slash optional with a ?, and there is no need for .*$.
In the subdirectory you ignore anything not in the subdirectory for rewrites using RewriteBase /development/ sending everything to /development/index.php where the request is not a file or directory.
Give the following a try:
/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^development/?
RewriteRule . /index.php [L]
</IfModule>
/development/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /development/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /development/index.php [L]
</IfModule>
I have a wordpress hosting site www.mysite.com/myBlog . The wordpress installation is done inside public_html/www/myBlog folder inside my host folder.
I also have a folder public_html/www/myName which redirects me to a domain myName.com
Although this works fine but inside myName folder i have files like index.html. acad.html, worexp.html
clicking on them i expect a behavior like
myName.com/index.html
myName.com/acad.html
myName.com/workex.html
though i get it as myname.com only.
I found htaccess rules in myName folder as :
Redirect http://mydomainName.com/myName/+
# 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
RewriteCond %{HTTP_HOST} ^mydomainName.com$
RewriteRule ^/?$ "http\:\/\/www\.mydomainName\.com\/myBlog" [R=301,L]
Can anyone help me with whats wrong with the htaccess file ?
More details:
My WordPress blog has something messed up. I can go to my blog and homepage works fine but when i try to go to any post it throws an 403 error. Apache forbidden.
Tried talking to web host for permissions its ok.
checked htaccess. Replaced code by default code stil not working.
Removed permalinks to default deleted htaccess created new permalinks.
Gave permissions to all the files in blog directory
Rewrote robots.txt Blog url is : www.windowsvj.com
Wordpress community is not able to suggest something very helpful too.
Current Redirect rule code in .htaccess is :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wpblog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wpblog/index.php [L]
</IfModule>
# END WordPress
This could be the result of FollowSymLinks being disabled in the server configuration. Simply adding Options +FollowSymlinks to the .htaccess file could do the trick.
Instead of using the flag [L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wpblog/
RewriteRule ^index\.php$ - [L] <---
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wpblog/index.php [L] <---
</IfModule>
# END WordPress
Try using [QSA]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wpblog/
RewriteRule ^index\.php$ - [QSA] <---
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wpblog/index.php [QSA] <---
</IfModule>
# END WordPress
How [L] works is if the RewriteRule matches
RewriteRule . /wpblog/index.php [L]
Then all other rewrites after this RewriteRule are ignored as stated on the Apache website
"In most contexts, this means that if the rule matches, no further rules will be processed." http://httpd.apache.org/docs/current/rewrite/flags.html
Here is a link with more information on .htaccess flags
http://httpd.apache.org/docs/current/rewrite/flags.html
Hope this works for you :P
I have wordpress installed in subdirectory folder named "thumbs". I also followed the steps here.
Everything works fine but if I go to www.mysite.com/wp-admin it redirects me to www.mysite.com/thumbs/wp-admin, I don't want that to happen because I want the subdirectory folder to be secret.
So what I want is if I visit or somebody visit www.mysite.com/wp-admin I want the wordpress 404 error page to display. Thanks in advance for the help.
What am I missing?
You should modify your root .htaccess (not thumbs/.htaccess) file to add a rule for wp-admin, e.g. :
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin - [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Change your HTACCESS with this code
# Switch rewrite engine off in case this was installed under HostPay.
RewriteEngine Off
SetEnv DEFAULT_PHP_VERSION 53
DirectoryIndex index.cgi index.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