How to add wildcard to DNS for wordpress multisite in Kloxo? - wildcard

I want to add Wildcard to DNS in my VPS (for setup Wordpress3.3.2 multisite). I have Kloxo, and when i want to add it from Manage DNS ( in Domain Adm ), i face with this error.
Alert: invalid_subdomain
Also i removed:
// Validates subdomain
if (!preg_match("/^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$/", $param['hostname'])) {
throw new lxexception('invalid_subdomain', 'hostname');
}
from /usr/local/lxlabs/kloxo/httpdocs/htmllib/lib/dns/dnsbaselib.php, but now sub-domains shows my IP address home.
I want to setup it for this domain:310blog.com ,and my ip server is 178.162.231.63. ( for example when i make a sub-domain : http://saman.310blog.com/, it shows Kloxo default page )
How can i fix it?

I solved it! if you want to add a wildcard into your Kloxo admin. You should follow these steps:
In your admin panel: Domain Adm->Manage DNS->Add A, in Hostname field you should enter:
*
And in Value field:
YOU_IP_ADDRESS
When you press add, maybe you face with invalid_subdomain error. If this happens, you should edit "dnsbaselib.php" in /usr/local/lxlabs/kloxo/httpdocs/htmllib/lib/dns/dnsbaselib.php, from your server, and remove this condition from line 104,
// Validates subdomain
if (!preg_match("/^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$/", $param['hostname'])) {
throw new lxexception('invalid_subdomain', 'hostname');
}
After that retry first step.
After step one, you need to edit httpd.conf in this path: /etc/httpd/conf/httpd.conf, and add this :
<VirtualHost YOUR_IP_ADDRESS:80>
ServerName YOUR_DOMAIN.com
ServerAlias *.YOUR_RDOMAIN.com
DocumentRoot /home/DOMAIN_DIR/YOUR_DOMAIN.com/
DirectoryIndex index.php index.html index.shtml index.htm default.htm Default.aspx Default.asp index.pl
ScriptAlias /awstats/ /home/kloxo/httpd/awstats/wwwroot/cgi-bin/
SuexecUserGroup USERNAME USERNAME </VirtualHost>
You have to use your IP address instead of YOUR_IP_ADDRESS, your domain name instead of YOUR_DOMAIN.com, your domain folder instead of DOMAIN_DIR and your username instead of USERNAME.
3. after that restart your httpd service.
/etc/init.d/httpd restart

Related

Multiple WordPress Sub directories AWS Linux/Apache

I am new to both word press and Linux and have been experiencing issues when attempting to setup multiple word press staging sites.
What I have currently,
4 Sub-Directories
/var/www/html/Sub1
/var/www/html/Sub2
/var/www/html/Sub3
/var/www/html/Sub4
I have configured my go Daddy domain to point to AWS nameservers. I have also associated an elastic IP to my EC2 instance and within Route 53 I have setup the following
myDomain.com pointing to elastic IP
subdomain1.mydomain.com pointing to elastic IP
subdomain2.mydomain.com pointing to elastic IP
subdomain3.,ydomain.com pointing to elastic IP
If I go to the following URL
mydomain.com/Sub1 it shows my wp blog and mydomain.com/Sub1/wp-admin works perfect same for the following
mydomain.com/Sub2 & mydomain.com/Sub2/wp-admin/
mydomain.com/Sub3 & mydomain.com/Sub3/wp-admin/
mydomain.com/Sub4 & mydomain.com/Sub4/wp-admin/
What I really want to have happen is
mydomain.com point to the first subdirectory site
subdomain1.mydomain.com point to the second subdirectory site
subdomain2.mydomain.com point to the third subdirectory site
subdomain3.mydomain.com point to the fourth subdirectory site
I have been reading through blogs, troubleshooting sites and tutorials but I cannot figure out how to achieve the above.
I tried create virtual hosts in the apache conf file /etc/httpd/conf/httpd.conf one for each sub directory site. I could achieve the first part of the problem, where mydomain.com did point to the first subdirectory site and subdomain1.mydomain.com pointed to the second subdirectory site. However the issue was if i tried to look for mydomain.com/wp-admin I got an error as there was some sort of redirection happening for example:
mydomain.com/wp-admin tried to redirect to mydomain.com/Sub1/wp-admin
Below is what the virtual host config updates I had made :
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/html/Sub1
<Directory /var/www/html/Sub1>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>
I had also updated the main
section of the conf file to update AllowOverride none to All
Can someone point me in the right direction as im not sure if i have missed something here?
Thanks in advance.

WordPress multisite setup as subdomain - wildcard DNS record setup

I am new to WP multisite environment. I want to setup multisite in my local Ubuntu 14.04 environment. I already have localhost for my main site configured as carbazarlocal.com and its running OK. When I go to Tools > Network Setup I can see two options - Sub-domain and Sub-directory. I want to setup my multisites as sub-domains like dealer1.carbazarlocal.com, dealer2.carbazarlocal.com etc.
On this page WordPress says "You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality". How to do this and where?
In /etc/hosts I have the following entry:
127.0.0.1 carbazarlocal.com
In /etc/apache2/apache2.conf I have the following:
<Directory /var/www/html/carbazar>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
In /etc/apache2/sites-available/carbazarlocal.com.conf I have this:
<VirtualHost *:80>
ServerAdmin admin#carbazarlocal.com
ServerName carbazarlocal.com
ServerAlias *.carbazarlocal.com
DocumentRoot /var/www/html/carbazar
</VirtualHost>
And in /var/www/html/carbazar/wp-config I have this:
define('WP_ALLOW_MULTISITE', true);
What else I need to do and where to complete the following step:
"You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality"?
If you use Apache server then ...
In the httpd.conf file, or in the include file containing the VirtualHost section for your web account, add a line like this (if it is not already present):
ServerAlias *.example.com
Also create a wildcard DNS record like:
*.example.com A 192.0.43.10
REF https://codex.wordpress.org/Configuring_Wildcard_Subdomains

How can I have a dot(.) in my WordPress URL on WAMP Vhost on localhost

I have defined a VirtualHost in my wamp/bin/apache/apache2.4.17/conf/extra/httpd-vhosts.conf file as below:
<VirtualHost *:80>
ServerName www.site.local
DocumentRoot h:/dev/wamp3/www/site
<Directory "h:/dev/wamp3/www/site">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
The WordPress site is available at www.site.local when I visit the homepage.
However, if visit any posts or pages, the URL turns to http://localhost/site/post-name, where as I am expecting the URL to be http://www.site.local/post-name.
Kindly suggest.
Check your .htaccess file and httpd.conf file for any rewrite rules that might be put in there. If there are none, you likely entered "localhost" as the url in your Wordpress settings. Wordpress always defaults to a single url per page, and will redirect wrongly formed urls. This includes the domain name.
Go to wp-admin in your wordpress installation, then to Settings > General. Change WordPress Address (URL) and Site Address (URL) (if possible) to the url you want. If you are using a non-default installation of Wordpress, such settings might be located in wp-config.php or wp-config-local.php.
Check your wp_options table (database prefix may differ), and look for the rows where option_name name is siteurl and home. Then check that the option_value for each is http://www.site.local.
Or run the following query on your database:
UPDATE `wp_options` SET `option_value` = 'http://www.site.local' WHERE `option_name` IN ('siteurl', 'home');

How to prevent WordPress setup in 'blog' subdomain, redirecting to 'www' when trying to finish Installation

I have a main site http://www.example.com that's written in another language (Ruby/Rails). I want a wordpress blog installed in http://blog.example.com. I have control over the server and DNS.
I have created the necessary CNAME record for the 'blog' subdomain. But after setting up apache and restarting it, when I visit http://blog.example.com, for the final installation steps, I'm redirected to http://www.example.com/wp-admin/install.php.
Also now when I try to visit the main site http://www.example.com, I'm being redirected to the above wordpress install page.
How can I make it work like this: the blog should only reside in blog.example.com path, and the main site should be accessible via http://www.example.com.
Removing the www subdomain is not an option as it's been like that for awhile for the main site. It might be ok, if somehow a redirect can be setup from www to non-www url, though I'm not aware how to set it up.
Please suggest.
Here's the main site's apache conf:
<VirtualHost *:80>
ProxyPreserveHost On
ServerAdmin webmaster#localhost
ServerName http://www.example.com
ServerAlias example.com
DocumentRoot /home/apps/example/current/public
<Directory /home/apps/example/current/public>
AllowOverride all
Options -MultiViews
</Directory>
#RewriteEngine On
#Redirect / http://example.com/
</VirtualHost>
Here's the apache conf for the wordpress under 'blog' subdomain:
<VirtualHost *:80>
ServerName blog.example.com
ServerAlias blog.example.com
ServerAdmin webmaster#localhost
DocumentRoot /home/apps/example_blog/wordpress_blog
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/apps/example_blog/wordpress_blog>
AllowOverride All
</Directory>
</VirtualHost>
WordPress has domain references in the database and the code which will throw your permalinks off and cause bad redirects. These renegade URLs should appear as 404's on your root domain (example.com). If not I'd double check the root domain with the sub domain removed from the vhosts.
I don't see any issues with your current vhost configuration. I would also try testing the domains in isolation if you suspect its vhost related. I suspect its a WordPress site url issue.
Assuming the database records are incorrect.
Log into phpMyAdmin or other database manager.
Select your WP database.
Go into the wp_options table (wp_ prefix may be different).
Look for the record's with option name = "siteurl" & "home".
Edit these records to reflect your new domain name.
Here's the WordPress documentation on how to switch a sites urls schema.
Document
Your problem is likely deep in various DB references throughout your WP project. I've run into this problem deploying WP before. You'll need to edit the DB directly to fix the issues.
Export your WordPress DB with phpMyAdmin or SequelPro (something that gets you a clean .sql file)
Use a text editor like Sublime or Atom, search for "www.example.com" and replace all with "blog.example.com" then save.
Upload DB to prod location and you should see these errors go away.
This should not happen if your virtual host is configured correctly
but still as your tables are not created so you can only do one try with this step :
you can add in your wp-config.php file the following parameter
define('wp_site_domain', 'blog.example.com');
This will force the wordpress to follow blog.example.com

Nginx url rewrite rules

I have URL like this:
http://example.com/site1
http://example.com/site2
... ...
http://example.com/siten
Yes, there are a list of sites.
But actually I would like to access the subsites by( take site1 for example ):
http://site1.example.com
What I have done in nginx.conf was :
if ($host = site1\.example\.com){
rewrite ^/(.*) /example.com/site1/$1 break;
}
Yeah, test in local machine and I have edited /etc/hosts:
127.0.0.1 example.com
But not work. Can anyone explains?
You MUST specify CNAME record for subdomain feature. Without it, no web server config rule will work.
In your DNS record management panel (whatever you use), you must create subdomain.domain.com and point DNS A record to IP where is domain.com is routed.
For local machine find hosts file, open it with administrator privileges and add 127.0.0.1 subdomain.domain.com in new line.

Resources