Skip to main content
Code formatting (backtick "fences" must go on lines by themselves)
Source Link
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

So I have WordPress installed in /wp/ but I want all WordPress URLs to be rewritten to appear in the root directory. I currently have this working (see below) but I want to change my .htaccess so it doesn't break other subdirectories.

For example, if I want to visit www.example.com/images/image.png, it currently reroutes me to a 404 page on WordPress.

Is this even possible with .htaccess?

Current code:

RewriteEngine on

#Wordpress
# Rewrites all URLS without wp in them
RewriteCond %{REQUEST_URI} !^/wp/

# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /wp/$1 [L]

Update: Tested MrWhite's suggestion with Incognito mode and a second browser. No effect. New .htaccess file:

RewriteEngine on

#Wordpress
# Rewrites all URLS without wp in them
RewriteCond %{REQUEST_URI} !^/wp/

# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /wp/$1 [L]
# Request does not map to an existing file
RewriteCond %{REQUEST_FILENAME} !-f```f

So I have WordPress installed in /wp/ but I want all WordPress URLs to be rewritten to appear in the root directory. I currently have this working (see below) but I want to change my .htaccess so it doesn't break other subdirectories.

For example, if I want to visit www.example.com/images/image.png, it currently reroutes me to a 404 page on WordPress.

Is this even possible with .htaccess?

Current code:

RewriteEngine on

#Wordpress
# Rewrites all URLS without wp in them
RewriteCond %{REQUEST_URI} !^/wp/

# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /wp/$1 [L]

Update: Tested MrWhite's suggestion with Incognito mode and a second browser. No effect. New .htaccess file:

RewriteEngine on

#Wordpress
# Rewrites all URLS without wp in them
RewriteCond %{REQUEST_URI} !^/wp/

# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /wp/$1 [L]
# Request does not map to an existing file
RewriteCond %{REQUEST_FILENAME} !-f```

So I have WordPress installed in /wp/ but I want all WordPress URLs to be rewritten to appear in the root directory. I currently have this working (see below) but I want to change my .htaccess so it doesn't break other subdirectories.

For example, if I want to visit www.example.com/images/image.png, it currently reroutes me to a 404 page on WordPress.

Is this even possible with .htaccess?

Current code:

RewriteEngine on

#Wordpress
# Rewrites all URLS without wp in them
RewriteCond %{REQUEST_URI} !^/wp/

# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /wp/$1 [L]

Update: Tested MrWhite's suggestion with Incognito mode and a second browser. No effect. New .htaccess file:

RewriteEngine on

#Wordpress
# Rewrites all URLS without wp in them
RewriteCond %{REQUEST_URI} !^/wp/

# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /wp/$1 [L]
# Request does not map to an existing file
RewriteCond %{REQUEST_FILENAME} !-f
copy of updated `.htaccess` file for MrWhite
Source Link

So I have WordPress installed in /wp/ but I want all WordPress URLs to be rewritten to appear in the root directory. I currently have this working (see below) but I want to change my .htaccess so it doesn't break other subdirectories.

For example, if I want to visit www.example.com/images/image.png, it currently reroutes me to a 404 page on WordPress.

Is this even possible with .htaccess?

Current code:

RewriteEngine on

#Wordpress
# Rewrites all URLS without wp in them
RewriteCond %{REQUEST_URI} !^/wp/

# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /wp/$1 [L]

Update: Tested MrWhite's suggestion with Incognito mode and a second browser. No effect. New .htaccess file:

RewriteEngine on

#Wordpress
# Rewrites all URLS without wp in them
RewriteCond %{REQUEST_URI} !^/wp/

# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /wp/$1 [L]
# Request does not map to an existing file
RewriteCond %{REQUEST_FILENAME} !-f```

So I have WordPress installed in /wp/ but I want all WordPress URLs to be rewritten to appear in the root directory. I currently have this working (see below) but I want to change my .htaccess so it doesn't break other subdirectories.

For example, if I want to visit www.example.com/images/image.png, it currently reroutes me to a 404 page on WordPress.

Is this even possible with .htaccess?

Current code:

RewriteEngine on

#Wordpress
# Rewrites all URLS without wp in them
RewriteCond %{REQUEST_URI} !^/wp/

# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /wp/$1 [L]

So I have WordPress installed in /wp/ but I want all WordPress URLs to be rewritten to appear in the root directory. I currently have this working (see below) but I want to change my .htaccess so it doesn't break other subdirectories.

For example, if I want to visit www.example.com/images/image.png, it currently reroutes me to a 404 page on WordPress.

Is this even possible with .htaccess?

Current code:

RewriteEngine on

#Wordpress
# Rewrites all URLS without wp in them
RewriteCond %{REQUEST_URI} !^/wp/

# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /wp/$1 [L]

Update: Tested MrWhite's suggestion with Incognito mode and a second browser. No effect. New .htaccess file:

RewriteEngine on

#Wordpress
# Rewrites all URLS without wp in them
RewriteCond %{REQUEST_URI} !^/wp/

# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /wp/$1 [L]
# Request does not map to an existing file
RewriteCond %{REQUEST_FILENAME} !-f```
edited tags; edited title
Link

.htaccess rewritingRewrite Wordpress Subdirectory without breaking other subdirectories

Formatting, exemplified domain according to RFC2606 (please use "example.com")
Source Link
MrWhite
  • 43.1k
  • 4
  • 50
  • 90
Loading
Source Link
Loading