I'm trying to set up a virtualhost on my machine for a wordpress project
I added this to the http-vhosts.conf in Apache
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\wordpresstest"
ServerName myapplication.dev
<Directory "C:\xampp\htdocs\wordpresstest">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I added this line to the windows hosts file
127.0.0.1 myapplication.dev
And I added these lines in wp-config
define('WP_HOME','http://myapplication.dev');
define('WP_SITEURL','http://myapplication.dev');
I also added a plugin to allow relative URLs across wordpress
However, when I access http://myapplication.dev, the first page of my website is there, but none of the links work ! They all send a 500 error page
Ok, found the solution thanks to this link : https://gist.github.com/JustThomas/141ebe0764d43188d4f2
I changed my .htaccess file
Before :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpressTest/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpressTest/index.php [L]
</IfModule>
# END WordPress
After :
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
Related
I am trying to create a subdomain sub.domain.com that displays domain.com/sub without changing the address bar.
I've come up with the following .htaccess rule based on other questions made here:
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^((?!sub/).*)$ /sub/$1 [L,NC]
The problem is I'm using a WordPress instance and my .htaccess currently looks like this now:
# 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
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^((?!sub/).*)$ /sub/$1 [L,NC]
But when I browse sub.domain.com I'm being redirected to my homepage (domain.com) from WordPress. How can I do this correctly?
Tried to change it to:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^((?!sub/).*)$ /sub/$1 [NC]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>
But it is still not working
You have to create a virtual host in apache config.
<VirtualHost *:80>
ServerName sub.domain.com
DocumentRoot /var/www/sub
</VirtualHost>
Or VirtualDocumentRoot if mod_vhosts_alias is enabled.
<VirtualHost *:80>
ServerName sub.domain.com
ServerAlias *.domain.com
VirtualDocumentRoot /var/www/%1
</VirtualHost>
In above I am pointing it to /sub directory if it exists. After all changes restart the server.
You can add below line of code in your wp-config.php files
define('WP_HOME','http://sub.domain.com');
define('WP_SITEURL','http://sub.domain.com');
I have put my wordpress files inside a folder wordpress instead of root.
I am able to access my site as www.example.com/wordpress
But i want to access it as www.example.com, want to hide wordpress in url.
my .htaccess file is as
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
How can i do this?
Try this:
Add this to the .htaccess in your root directory:
Options FollowSymLinks
RewriteEngine On
RewriteRule (.*) wordpress/($1) [NC,L]
I'm using the AWS/Bitnami/Wordpress stack to install WP multisite (3.5.1-1) with a subdirectory structure.
I can create sub-sites, however trying to view a sub-sites dashboard results in a 'redirect loop'. Additionally, when I view a sub-site it appears that the theme/plugins are broken.
I have installed multisites before with no issues, so am assuming that this is something related to Bitnami itself. I've searched through the database to confirm that all site URLs are the same as I read that that was a common solution, however I'm still facing the same problem.
Here is what's in my .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
Try this:
delete your .htaccess file.
Then edit /opt/bitnami/apps/wordpress/conf/wordpress.conf and replace all content with this:
<IfVersion < 2.3 >
NameVirtualHost *:80
</IfVersion>
<VirtualHost *:80>
ServerAdmin mail#example.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
<Directory "/opt/bitnami/apps/wordpress/htdocs">
Options +MultiViews +FollowSymLinks
AllowOverride None
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END WordPress
</Directory>
</VirtualHost>
Then restart apache using this command:
sudo /opt/bitnami/ctlscript.sh restart
I have the following code in my Apache htaccess file that is used to redirect all www URLs to non-www URLs on wordpress. This works for all URLs except the root.
For example, http://www.noshon.it/recipes redirects properly to http://noshon.it/recipes. However, http://www.noshon.it incorrectly redirects to http://noshon.it/wordpress (where it receives a 404 page).
I can't figure out why all ULRs work except for the root. Any help would be much appreciated.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.noshon\.it$ [NC]
RewriteRule ^(.*)$ http://noshon.it/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Thanks to #WebChemist for suggesting that the redirect was happening in another file. I located a file named wordpress.conf in the /opt/bitnami/apps/wordpress/conf/ directory of the Bitnami EC2 instance. This file had the following code:
# App url moved to root
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
#Alias /wordpress/ "/opt/bitnami/apps/wordpress/htdocs/"
#Alias /wordpress "/opt/bitnami/apps/wordpress/htdocs"
<Directory "/opt/bitnami/apps/wordpress/htdocs">
Options Indexes MultiViews +FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
RewriteEngine On
#RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
<//Directory>
# Uncomment the following lines to see your application in the root
# of your URL. This is not compatible with more than one application.
RewriteEngine On
RewriteRule ^/$ /wordpress/ [PT]
The rewrite was occurring in the last line of this file:
RewriteRule ^/$ /wordpress/ [PT]
I modified this file to the following and the redirects are working now:
# App url moved to root
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
#Alias /wordpress/ "/opt/bitnami/apps/wordpress/htdocs/"
#Alias /wordpress "/opt/bitnami/apps/wordpress/htdocs"
<Directory "/opt/bitnami/apps/wordpress/htdocs">
Options Indexes MultiViews +FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
RewriteEngine On
#RewriteBase /wordpress/
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
<//Directory>
# Uncomment the following lines to see your application in the root
# of your URL. This is not compatible with more than one application.
#RewriteEngine On
#RewriteRule ^/$ /wordpress/ [PT]
I have a WordPress install that uses a fairly vanilla .htaccess file. There are some files in a directory on the server that users should be able to access via a link sent in an email. That link contains URL variables, including a second URL. Something like:
www.mysite.com/email/email.php?src=http://source.com&title=sample
My mod_rewrite rules should allow access to it, but as long as the link contains '//' the user sees a 404 page on the WordPress site, rather than accessing the intended email.php file.
Here's the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
#RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]
RewriteCond %{REQUEST_URI} ^/email$
RewriteRule . - [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
<IfModule mod_security.c>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>
</IfModule>
Any ideas on what I've done wrong?