Remove directory name from url Wordpress

12,172

Solution 1

1) in your dashboard, go to settings -> general and make sure

a) wordpress directory -> http://mydomain.com/wp

b) site address -> http://mydomain.com

2) move your index.php from subdirectory to the root (MOVE, don't just copy)

3) edit your index.php to read

    /** Loads the WordPress Environment and Template */
    require('./wp/wp-blog-header.php');

where "wp" is your subdirectory

4) delete any .htaccess file in the subdirectory

5) add this to your .htaccess in the root

# 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

Under this setup, your wordpress installation will be located in /wp/ directory. Visitors will visit your site using http://mydomain.com.

If you want to have a good read-up on everything so you know exactly what you're doing, read this https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

Solution 2

Add (or edit) the .htaccess file and put this:

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

This basically creates a rewrite rule for your apache server and all traffic is redirected according the RewriteBase directive.

Share:
12,172
user2688562
Author by

user2688562

Updated on June 19, 2022

Comments

  • user2688562
    user2688562 almost 2 years

    I have a website on www.example.com. On that domain Wordpress website is in directory wp.

    So to access my wordpress website you should go to www.example.com/wp and that is the main website.

    In root i have index.html where you choose language and then go to Wordpress website

    What i need sounds simple! :) I want to remove wp from url using .htaccess or whatever else could do the trick, so when browse Wordpress website it shouild work without wp!

    I must note that website must stay in wp folder!

    Is this achievable?

  • user2688562
    user2688562 over 10 years
    Where should i put this htaccess file? Inside root folder or inside wp folder?
  • Bud Damyanov
    Bud Damyanov over 10 years
    The file should be called ".htaccess", mark the dot at the beginning. It should be placed on root of your web server, i.e. on www.example.com