1

I have wordpress installed in rootfolder in http://example.com . I have created new folder named world http://example.com/world , I need htaccess to work on that particular folder alone , Is it possible?

My htaccess I need to use for folder world is given below. I added this in rootfolder htaccess and I got internal server error and hence I don't want to disturb the root folder.

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*)(\/?)$ / [QSA,NC,L]

My root folder htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
6
  • Your root .htaccess already has WP rewrite rule isn't it? If yes post your complete DOCUMENT_ROOT/.htaccess
    – anubhava
    Sep 25, 2013 at 18:22
  • @anubhava : hi sir i have updated. Sep 25, 2013 at 18:25
  • Ok very good now you want to this folder /world independent of wordpress right?
    – anubhava
    Sep 25, 2013 at 18:28
  • You have to put your .htaccess file inside the world folder and it should work. If not, you have to add AllowOverride All option in your site configuration.
    – Manolo
    Sep 25, 2013 at 18:29
  • @anubhava : yes sir :) Sep 25, 2013 at 18:31

1 Answer 1

1

Replace your DOCUMENT_ROOT/.htaccess with this code:

# BEGIN WordPress
<IfModule mod_rewrite.c>

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

# don't do anything for /world folder
RewriteRule ^world/ - [L,NC]

RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>
# END WordPress

Replace your DOCUMENT_ROOT/world/.htaccess with this code:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /world/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ index.php [L]
6
  • hi , i have updated now domain.com/world/anythingrandom.php must point to domain.com/world/index.php . why it is showing not found url of wordpress Sep 25, 2013 at 18:36
  • check the updated code for DOCUMENT_ROOT/.htaccess and world/.htaccess
    – anubhava
    Sep 25, 2013 at 18:41
  • 1
    thanks working perfect :) i see you are the one answering all the .htaccess questions..where did u learn this ? do you have good tutorial link ? Sep 25, 2013 at 18:44
  • lol :) No haven't see any complete tutorial on mod_rewrite. I am not even on admin side, just learnt it because of my inherent interest in regex. Q&A on this site are best set of knowledge-base for this.
    – anubhava
    Sep 25, 2013 at 18:47
  • 1
    lol :) Q&A in this site .htaccess tag is always has your answer :D Sep 25, 2013 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.