MDanz Posted December 4, 2014 Share Posted December 4, 2014 I have multiple folders(domains) in my public_html folder. In my public_html folder i have a .htaccess file. I want to do mod rewrite on a specific domain e.g. www.test.com Here is the mod rewrite wordpress has written for each domain # 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 The above code is in my .htaccess file multiple times, so i don't know which one to edit. I want to add the below code to the domain www.test.com but i don't know which one to edit. RewriteRule ^page/(.*) ads/page/$1 [R=301,L] RewriteRule ^page/(.*)/ ads/page/$1/ [R=301,L] What is the solution? Any help, greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/292900-mod-rewrite-for-specific-domain-wordpress/ Share on other sites More sharing options...
requinix Posted December 4, 2014 Share Posted December 4, 2014 I don't understand how you can have stuff "written for each domain", and at the same time not know which domain each was written for. Quote Link to comment https://forums.phpfreaks.com/topic/292900-mod-rewrite-for-specific-domain-wordpress/#findComment-1498563 Share on other sites More sharing options...
MDanz Posted December 4, 2014 Author Share Posted December 4, 2014 I don't understand how you can have stuff "written for each domain", and at the same time not know which domain each was written for. It's an assumption, in my .htaccess file in the root folder i have several of the below code written. So i don't know which one to change for the specific domain. # 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 Is there a workaround of putting .htaccess in wp-content folder? Quote Link to comment https://forums.phpfreaks.com/topic/292900-mod-rewrite-for-specific-domain-wordpress/#findComment-1498568 Share on other sites More sharing options...
CroNiX Posted December 4, 2014 Share Posted December 4, 2014 You can use %{HTTP_HOST} in a RewriteCond to detect the domain name, and RewriteRule(s) specific to that domain name. But it seems like each WP "site" should have it's own .htaccess and not one to run them all. .htaccess files cascade. Like if you had: /public_html/.htaccess /public_html/site1 /public_html/site2 That .htaccess at the root (public_html) would affect both the /site1 and /site2 dirs. Instead you'd want a separate htaccess to be within each of the /site1 and /site2 dirs. This would be more clean with each site having it's own htaccess file, and then you wouldn't have to muck around with domain specific rules which can get very complex the more sites you're trying to control with a single htaccess file. Quote Link to comment https://forums.phpfreaks.com/topic/292900-mod-rewrite-for-specific-domain-wordpress/#findComment-1498571 Share on other sites More sharing options...
MDanz Posted December 4, 2014 Author Share Posted December 4, 2014 You can use %{HTTP_HOST} in a RewriteCond to detect the domain name, and RewriteRule(s) specific to that domain name. But it seems like each WP "site" should have it's own .htaccess and not one to run them all. .htaccess files cascade. Like if you had: /public_html/.htaccess /public_html/site1 /public_html/site2 That .htaccess at the root (public_html) would affect both the /site1 and /site2 dirs. Instead you'd want a separate htaccess to be within each of the /site1 and /site2 dirs. This would be more clean with each site having it's own htaccess file, and then you wouldn't have to muck around with domain specific rules which can get very complex the more sites you're trying to control with a single htaccess file. The way my clients website is set up it has /public_html/website 1 /public_html/website 2 /public_html/wp-content /public_html/website 3 The website i want to mod rewrite on is /public_html/wp-content. If i put a .htaccess file in /wp-content will that override the .htaccess file in the public_html folder? Thanks for help Quote Link to comment https://forums.phpfreaks.com/topic/292900-mod-rewrite-for-specific-domain-wordpress/#findComment-1498575 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.