Wordpress redirect to subdirectory not working well

admin

Administrator
Staff member
Ok so there are a lot of questions that are close to what I want on SO but none of them seem to work for me. I have an old site that I am trying to replace with a wordpress site. I have moved the wordpress site from a dev site and I have used the <a href="http://interconnectit.com/products/search-and-replace-for-wordpress-databases/" rel="nofollow noreferrer">search and replace script</a> to fix all the urls in the database. All seems good, so what I did was copy all the wordpress files into a folder <em>root/wordpress</em>.
I still have the old site files sitting at the root level but I want the url when visiting to be <em><a href="http://example.com" rel="nofollow noreferrer">http://example.com</a></em> and not <em><a href="http://example.com/wordpress" rel="nofollow noreferrer">http://example.com/wordpress</a></em>
So I added this htaccess file to the root
<h1>.htaccess</h1>
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC]
RewriteCond %{REQUEST_URI} !^/wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wordpress/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC]
RewriteRule ^(/)?$ wordpress/index.php [L]
The homepage works. I get everything working fine when I visit <em><a href="http://example.com" rel="nofollow noreferrer">http://example.com</a></em>. However, when I navigate to another page I get redirected to the roots index.php file and the resources aren't loading (images, stylesheets, javascript files, etc.). The admin pages work fine also. So I don't know why it doesn't work. I also have a very long htaccess file in the wordpress directory.
<h1>wordpress/.htaccess</h1>
Code:
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
&lt;/IfModule&gt;

# END WordPress

# BEGIN wtwp_cache
&lt;IfModule mod_mime.c&gt;

    # Text
    AddType text/css .css
    AddType application/x-javascript .js
    AddType text/html .html .htm
    AddType text/richtext .rtf .rtx
    AddType text/plain .txt
    AddType text/xml .xml

    # Image
    AddType image/gif .gif
    AddType image/x-icon .ico
    AddType image/jpeg .jpg .jpeg .jpe
    AddType image/png .png
    AddType image/svg+xml .svg .svgz

    # Video
    AddType video/asf .asf .asx .wax .wmv .wmx
    AddType video/avi .avi
    AddType video/quicktime .mov .qt
    AddType video/mp4 .mp4 .m4v
    AddType video/mpeg .mpeg .mpg .mpe

    # PDF
    AddType application/pdf .pdf

    # Flash
    AddType application/x-shockwave-flash .swf

    # Font
    AddType application/x-font-ttf .ttf .ttc
    AddType application/vnd.ms-fontobject .eot
    AddType application/x-font-otf .otf

    # Audio
    AddType audio/mpeg .mp3 .m4a
    AddType audio/ogg .ogg
    AddType audio/wav .wav
    AddType audio/wma .wma

    # Zip/Tar
    AddType application/x-tar .tar
    AddType application/x-gzip .gz .gzip
    AddType application/zip .zip
&lt;/IfModule&gt;

&lt;IfModule mod_expires.c&gt;
    ExpiresActive On

    # Text
    ExpiresByType text/css A31536000
    ExpiresByType application/x-javascript A31536000
    ExpiresByType text/html A3600
    ExpiresByType text/richtext A3600
    ExpiresByType text/plain A3600
    ExpiresByType text/xml A3600

    # Image
    ExpiresByType image/gif A31536000
    ExpiresByType image/x-icon A31536000
    ExpiresByType image/jpeg A31536000
    ExpiresByType image/png A31536000
    ExpiresByType image/svg+xml A31536000

    # Video
    ExpiresByType video/asf A31536000
    ExpiresByType video/avi A31536000
    ExpiresByType video/quicktime A31536000
    ExpiresByType video/mp4 A31536000
    ExpiresByType video/mpeg A31536000

    # PDF
    ExpiresByType application/pdf A31536000

    # Flash
    ExpiresByType application/x-shockwave-flash A31536000

    # Font
    ExpiresByType application/x-font-ttf A31536000
    ExpiresByType application/vnd.ms-fontobject A31536000
    ExpiresByType application/x-font-otf A31536000

    # Audio
    ExpiresByType audio/mpeg A31536000
    ExpiresByType audio/ogg A31536000
    ExpiresByType audio/wav A31536000
    ExpiresByType audio/wma A31536000

    # Zip/Tar
    ExpiresByType application/x-tar A31536000
    ExpiresByType application/x-gzip A31536000
    ExpiresByType application/zip A31536000
&lt;/IfModule&gt;
&lt;FilesMatch &quot;\.(?i:css|js|htm|html|rtf|rtx|txt|xml|gif|ico|jpg|jpeg|jpe|png|svg|svgz|asf|asx|wax|wmv|wmx|avi|mov|qt|mp4|m4v|mpeg|mpg|mpe|pdf|swf|ttf|ttc|eot|otf|mp3|m4a|ogg|wav|wma|tar|gz|gzip|zip)$&quot;&gt;
    &lt;IfModule mod_headers.c&gt;
        Header set Pragma &quot;public&quot;
        Header append Cache-Control &quot;public, must-revalidate, proxy-revalidate&quot;
        Header unset ETag
    &lt;/IfModule&gt;
&lt;/FilesMatch&gt;
&lt;FilesMatch &quot;\.(?i:css|js|gif|ico|jpg|jpeg|jpe|png|pdf|swf|ttf|ttc|eot|otf)$&quot;&gt;
    &lt;IfModule mod_headers.c&gt;
        Header unset Set-Cookie
    &lt;/IfModule&gt;
&lt;/FilesMatch&gt;
# END wtwp_cache

# BEGIN wtwp_security
&lt;IfModule mod_rewrite.c&gt;
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteRule ^wp-admin/includes/ - [F,L]
    RewriteRule !^wp-includes/ - [S=3]
    RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
    RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
    RewriteRule ^wp-includes/theme-compat/ - [F,L]
&lt;/IfModule&gt;
&lt;Files &quot;wp-config.php&quot;&gt;
    Order allow,deny
    Deny from all
&lt;/Files&gt;
Options -Indexes
# END wtwp_security
Any help would be greatly appreciated thanks!