Reputation: 25
I have a dedicated server with many parked domains, my subfolders have the structure "domain.com/pages/username" and if the user purchases a own domain then do the redirect with this code in htaccess file:
RewriteCond% {HTTP_HOST} ^ mynewdomain\.com $ [NC] RewriteCond% {DOCUMENT_ROOT} /pages/username/% {REQUEST_URI} /-d RewriteRule [^ /] $% {REQUEST_URI}/ [R = 301, L] RewriteCond% {ENV: REDIRECT_STATUS} ^ $ RewriteCond% {HTTP_HOST} ^ mynewdomain\.com $ [NC] RewriteRule ^ (. *) $ /pages/username/$ 1 [QSA, L]
But now as there are several domains and htaccess file size is getting larger. I wondered if something similar can be done from the domain configuration without editing the htaccess file. I do not use subdomains, Can I use CNAME or something similar for new domains? htaccess file weight affects page load?
Is it possible?
Thanks guys.
Upvotes: 0
Views: 647
Reputation: 302
You can use this .htaccess
# BEGIN WordPress
RewriteEngine On
RewriteBase /subdirectory-name/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdirectory-name/index.php [L]
# END WordPress
for more information please see this article https://welovewp.com/how-to-install-wordpress-in-a-subdirectory-with-htaccess-settings/
Thank you
Upvotes: 0
Reputation: 671
If you're the server administrator, you should not be using htaccess files for your configuration, you should be making the changes in the main config file for your server. If you're using Apache on Linux, this is typically located in /etc/apacheX/sites-available/
.
The exact same rules can be applied in a Directory section in the main configuration file.
See here for information on when not to use htaccess files.
Upvotes: 0