Jump to content

mod rewrite for specific domain wordpress


MDanz

Recommended Posts

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.


Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.