Why don’t you use WordPress core settings for doing this?
This is the recommended way and doesn’t need editing .htaccess or Apache config directly. You can find the details here in WP docs. I’m posting the steps here:
- After installing WP in the root dir, Go to the
Settings->General
and change these values: - WordPress Address (URL):
http://localhost/wordpress
- Site Address (URL):
http://localhost
- Save the settings and don’t worry about the errors
- Move all WP files to the
wordpress
sub-directory. - Copy (NOT MOVE!) the
index.php
and.htaccess
files from thewordpress
sub-directory into the root directory of your site - Edit the
index.php
placed in the root and change the line that says:
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
to the following:
require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
- Login to WP using
http://localhost/wordpress/wp-admin/
- Go to the
Settings->Permalinks
and save the settings (with no edit). This will regenerate.htaccess
file in the sub-directory to include/wordpress
path in it)
Now everything should work fine.
UPDATE: When you save the Permalinks, .htaccess
file in the sub-directory would be something like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
And .htaccess
in the root directory:
# 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
Note the differences in RewriteBase
rule and the last RewriteRule
rule. By adding these lines, WP would tell Apache, how to load the website by accessing the root directory of localhost (in addition to the edit in the root index.php
). These .htaccess files are the reason that there’s is no need to re-configure Apache.
UPDATE2: I usually use XAMPP on Windows, and Apache rewrite_module is activated bu default on it. Digging around WAMP, I found that this module isn’t activated by default on WAMP. This may be the reason .htaccess files are not working on your setup. See these links to activate this module. [1] , [2]
I hope this would help you.