Wordpress with my site - wordpress

I have a blog on wordpress, for example www/blog.com - folder
and my site example.com, www/example.com - folder.
I try integrate worpress with my site. example.com/blog - must go to wordpress index page, and example.com/blog/post_name must go to wordpress post.
apache conf
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/example.com
ServerAlias www.example.com
Alias /blog /var/www/blog.com
<Location /blog>
</Location>
</VirtualHost>
<Directory /var/www/example.com>
#code
</Directory>
<Directory /var/www/blog.com>
#code
</Directory>
In worpress admin panel i change:
WordPress Address (URL) to example.com/blog
Site Address (URL) to example.com
Permalink Settings to /blog/%postname%/
When i go to example.com/blog it work fine, but when i type
example.com/blog/post_name i have 404 error.
Edit:
request example.com/blog go to wordpress directory, but example.com/blog/post_name go to example.com index.php

check out this wordpress.org article. it will help you ensure that you have mod_rewrite enabled, along with inserting the AllowOverride FileInfo directive that I can already see you're missing within your VirtualHost. Don't forget to read on about the .htaccess file for your /blog (/var/www/blog.com) directory. You'll want to make sure your RewriteBase is set to /blog

Related

How to set a rewrite rule in Bitnami Wordpress

I have a bitnami apache2 wordpress site.
my htdocs is in the /opt/bitnami/apps/wordpress/htdocs directory and everything inside that has been moved to a directory called blogs which is in the same htdocs as below:
/opt/bitnami/apps/wordpress/htdocs/
/blogs
- contents
And now when I access blog.mydomain.com it gives the File permission error as below:
Forbidden You don't have permission to access this resource.
But when I access blog.mydomain.com/blogs I can see the content.
So, how I can redirect from blog.mydomain.com to blog.mydomain.com/blogs when someone hits blog.mydomain.com
Bitnami developer here!
If you don't plan to use the main domain as a double website setup, you could simply perform a redirection using the RedirectMatch directive in your VirtualHost.
If you use the original VirtualHost setup of the instance, add the following lines to /opt/bitnami/apache2/conf/bitnami/bitnami.conf:
...
<VirtualHost _default_:80>
+ RedirectMatch ^/$ /blog/
DocumentRoot "/opt/bitnami/apache2/htdocs"
<Directory "/opt/bitnami/apache2/htdocs">
...
</VirtualHost>
...
<VirtualHost _default_:443>
+ RedirectMatch ^/$ /blog/
DocumentRoot "/opt/bitnami/apache2/htdocs"
SSLEngine on
...
</VirtualHost>
...
Explanation: When the current URL matches the root of your domain, http(s)://YOUR-DOMAIN/, the server will redirect to the second argument of the directive, http(s)://YOUR-DOMAIN/blog
If are using another VirtualHost setup, just place this modification there.

Redirect Page Url to homepage `.htaccess`

I'm noob when it comes to .htaccess tricks.
However, I have a page http://example.com/register and when a user enters this URL, I want this page to redirect directly to Homepage or let's say any other page.
I've inserted following code inside .htaccess, but it's not working.
#Redirect to Homepage
Redirect 301 /register http://www.example.com/
Anything I'm missing here?
Check your apache server setting.
Is AllowOverride setted on your root directory.
For example:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
See How to Set AllowOverride all

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

Pointing domain name to server ip running XAMPP and wordpress

I installed XAMPP on my windows server and also installed Wordpress XAMPP module. I also bought a domain to point it to my server ip. Thing is , I want that when people enter mydomain.com , mydomain.com shows in the address bar and that it keeps showing while browsing.
First I tried to point the domain to my ip , and when I go to mydomain.com it shows mydomain.com/xampp
Then I tried to changing:DocumentRoot "C:\xampp\htdocs"
<Directory "C:\xampp\htdocs">
in httpd file in C:\xampp\apache\conf
to
DocumentRoot "C:\xampp\apps\wordpress\htdocs"
<Directory "C:\xampp\apps\wordpress\htdocs">
But this time when I enter mydomain.com it redirects to myipaddress.com/wordpress
All I want is:
1)When someone enters mydomain.com , he will see my wordpress home page.
2)Whenever a user is browsing mydomain.com , he will always see mydomain instead of myipaddress.
Any help would be appreciated.
Regards!
Type this at the bottom of your httpd file:
Alias /wordpress "C:/xampp/htdocs/wordpress/"
<Directory "C:/xampp/htdocs/wordpress/">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Please take note that the directory that I stated above is a sample of a default directory. I am having a hard time trying to figure out your directory but the above example should make sense. After typing the codes on your httpd file, go to the directory of xamp/apache/conf/extra/ and openup the httpd-vhosts file. Type this at the bottom of the httpd-vhosts file:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.yourdomain.com
ServerAlias yourdomain.com
ServerAdmin email#yourdomain.com
DocumentRoot "C:\xampp\htdocs\wordpress"
</VirtualHost>
Double check your host file if you already entered this line:
127.0.0.1 yourdomain.com
Restart your Apache webserver. Hope this helps!

How to point URL path to a wordpress folder

I currently have two sites, hosted on the same server using Apache virtual hosts.
http://www.example.com -> /var/www/sites/mysite (path to main website)
http://blog.example.com -> /var/www/sites/blog (path to wordpress folder)
I need my blog to be accessible from www.example.com/blog
I cannot move the wordpress installation into a 'blog' subdirectory of the mysite folder.
Using the Apache Alias directive, I can do the following in the configuration for www.example.com:
Alias /blog /var/www/sites/blog
and access the blog via www.example.com/blog
However the following fails to work with a 404
www.example.com/blog/a-permalink-post-title
I have also tried using the following but the 404 still persists.
AliasMatch /blog/(.*)$ /var/www/sites/blog/$1
The current virtual host configuration looks like this:
<VirtualHost *:80>
ServerName www.example.com
Alias /blog /var/www/sites/blog
DocumentRoot /var/www/sites/mysite
<Directory /var/www/sites/mysite>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
and for blog.example.com
<VirtualHost *:80>
ServerName blog.example.com
DocumentRoot /var/www/sites/blog
<Directory /var/www/sites/blog>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Would greatly appreciate any help with this.

Resources