Codeigniter – htaccess rewrite to hide wordpress folder

On root of my server, I have codeigniter with htaccess. I have created a wp/ folder along codeigniter’s sub-folders (e.g. application, config) in which I have placed all the wordpress files. Now when someone types

www.abc.com

i redirect him to

Read More
www.abc.com/wp/

but I want to hide wp in the url. How can I achieve this without modifying my current file structure? I want wordpress to be my site’s front and codeigniter to be my site’s backend. The file structure is shown below:

enter image description here

Related posts

1 comment

  1. In your root directory, create a .htaccess with following codes. This will map all your http requests to the /wp/ directory.

    # ==>Initializaion…
    Options -Indexes
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    
    # ==>Without this line, your /wp/ directory may become visible sometimes
    DirectorySlash Off
    
    # ==>Map everything to your /wp/ directory
    RewriteRule (.*) /wp/$1 [L]
    

    You also want to hide the /wp/ directoy from URL. For this, create another .htaccess in your /wp/ directory and write following lines:

    # ==>Initializaion…
    Options +FollowSymLinks
    RewriteBase /
    
    # ==>Set default file
    DirectoryIndex index.php
    
    #==> If the requested resource is NOT a file, or the URL contains “/wp/” anywhere in it,
    # then serve the default file instead
    RewriteCond %{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{THE_REQUEST} /wp/
    RewriteRule .* index.php [L]
    

    If someone types “/wp/” anywhere in the address bar, they will not see what is in it. Instead, they will see your homepage.

    You may have to adjust the code to suite your requirement.

Comments are closed.