Skip to content

Instantly share code, notes, and snippets.

@quinncomendant
Last active September 12, 2022 03:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save quinncomendant/fca75ba03f3a4b3bf6cf to your computer and use it in GitHub Desktop.
Save quinncomendant/fca75ba03f3a4b3bf6cf to your computer and use it in GitHub Desktop.
This .htaccess file works with Wordpress installed under a subdirectory wp/ inside the document root.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# Make the admin still accessible from /wp-admin
RewriteCond %{REQUEST_URI} ^/wp-admin/?(.*)
RewriteRule .* wp/wp-admin/$1 [L,R=301]
RewriteCond %{REQUEST_URI} ^/wp/?$
RewriteRule .* wp/wp-admin/ [L,R=301]
# Base is the URL path of the home directory
RewriteBase /
RewriteRule ^$ wp/index.php [L]
# Skip real files and directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise send it to WordPress
RewriteRule .* wp/index.php [L]
</IfModule>
# END WordPress
@arin-g
Copy link

arin-g commented Aug 6, 2021

Is this the .htaccess file for the root or the subdirectory?

@quinncomendant
Copy link
Author

@arin-g It's the main .htaccess file, that completely replaces the one installed by WP.

@davidduong90
Copy link

It works. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment