I just put a drupal 8 site online.
I developed this site in folder 'snew'.
The online site refers to that folder and drupal expects the files to be in this sub folder.
So everything refers to:
www.domain.com/snew/
And it should be the root of the website:
www.domain.com
How can i change this?
For most of my installs, I have Drupal running from subfolders. Here is what I do:
settings.php
Uncomment and modify this line:
# $base_url = 'http://www.example.com'; // NO trailing slash!
.htaccess (in your subfolder)
Unless there are server/web host-specific items to add, this can be left alone
.htaccss (in Web root)
Options -Indexes
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} !^www\.[yourdomain]\.[your TLD]$ [NC]
RewriteRule .* http://www..[yourdomain].[your TLD]/ [L,R=301]
RewriteRule ^$ production/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/[subfolder]%{REQUEST_URI} -f
RewriteRule .* [subfolder]/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*[subfolder]/index.php?q=$0 [QSA]
Hope this helps.
Related
I have a Wordpress installation in the root folder of my server and another Wordpress installation in a subfolder called "neueseite".
I can access the frontend of the page in the subfolder but not the admin area (backend). When I try to access it, it shows me a 404 error: https://paarkultur.ch/neueseite/wp-login.php
All URLs in the database contain the URL with the subfolder. I also tried different things with the .htaccess file. Nothing helped.
Here is the code inside the root directory's .htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
# Include in the next line all folders to exclude
RewriteCond %{REQUEST_URI} !(neueseite) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
And this is the code in the subfolders .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /neueseite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /neueseite/index.php [L]
</IfModule>
Can someone help me figure out what the problem could be?
I checked your nginx server and the below file is not located in the directory listed below:
https://paarkultur.ch/neueseite/wp-login.php
I can see that you have various core files such as wp-config.php, readme.html, etc but you do not have wp-login.php in that directory.
Anyway if you are trying to serve multiple sites from a single server then you are going the wrong way about it
I have a problem with a wordpress site as follows:
A website was built on http://example-domain.com.
I have build a wordpress site on http://example-domain.com/wordpress.
I want to delete everything in public.html folder and put a clean wordpress there.
The problem is that after I installed the clean wordpress, I keep getting redirected to the /wordpress subdirectory.
What I have tried:
Changed the site URL and home from example http://example-domain.com/wordpress to http://example-domain.com, copied a clean htaccess file in the new wp instalation.
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Before, I had 2 htaccess files, one just like the one mentioned above, that was located in the subdirectory and one in the root like this:
DirectoryIndex /wordpress/index.php
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
<IfModule mime_module>
AddHandler application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
Extra info: It is not a cache or cookie nor browser issue.
Update:
I was watching the Network tab in dev tools on Chrome and saw this error.
Any help would be greatly appreciated!
Did you changed the existing database urls from http://example-domain.com/wordpress to http://example-domain.com ?
Export the existing database, open in a text editor, do find-replace for the url's(from subdirectory to root directory) as mentioned above. Then import it into the new database. Once done, a fresh htaccess like this in the public/html root folder should be working fine.
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
I have a application that uses rewrite conditions, and then I added wordpress. I could not get /blog to rewrite properly.
Please see below for both HTACCESS files in root, and /blog (where wordpress is installed). I need to create a reference in root to allow /blog to work properly (im guessing). But how can I do this without breaking my other rewrite rules?
/.htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?sn=$1 [QSA,L]
#RewriteRule ^([a-zA-Z0-9/%-]+)$ index.php?sn=$1 [QSA]
Then in wordpress my wordpres install folder, i am simply doing:
/blog/.htaccess
#for blog directory only
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
... and all other rw conditions needed for caching, etc
The reason the error was persistent with this dual HTACCESS setup was because the /blog/.htaccess file was missing an additional line:
RewriteRule . /blog/index.php [L]
Once added, it operated fine. No chances needed to go into the root htaccess to reference the /blog/ rewrite conditions. This allows for a wordpress install in a blog folder, and above references dual HTACESS rules
I have the followind htaccess in my main root... but I want to exclude a subdomain folder to install a wordpress... actually the wordpress im trying to install is giving error ,, when I remove this htaccess the wordpress works fine... thanks
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
# Get rid of index.php
RewriteCond %{REQUEST_URI} /index\.php
RewriteRule (.*) index.php?rewrite=2 [L,QSA]
# Rewrite all directory-looking urls
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*) index.php?rewrite=1 [L,QSA]
# Try to route missing files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} public\/ [OR]
RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
RewriteRule . - [L]
# If the file doesn't exist, rewrite to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]
</IfModule>
To exclude a file from htaccess, you can place an htaccess file in the directory with a simple:
RewriteEngine On
Otherwise, in the root folder's htaccess file, you can add this right below the RewriteEngine On:
RewriteRule ^directory_you_want_to_protect - [L]
But I suspect that this is really a XY Problem here. You're probably going to need to rework or combine the htaccess rules that wordpress requires with the ones that you have right now. They may not be entirely compatible. If it's a matter not being able to run the installer, simply remove the root's htaccess file temporarily, install wordpress, then figure out how to combine the rules.
Here's a tricky one for y'all. I have a WordPress site installed on my server in the following directory:
public_html/priestessentrepreneur/dsa/blogdsa
I have divinesparkastrology.com pointed to public_html/priestessentrepreneur/dsa
I have priestessastrology.com pointed to public_html/priestessentrepreneur/dsa/blogdsa
So, my (singular) WordPress installation used to have the site URL set to http://www.divinesparkastrology.com/blogdsa but I recently changed it to http://www.priestessastrology.com/. When you type in http://www.divinesparkastrology.com/ you are correctly forward to the new url, http://www.priestessastrology.com/. However, if you try to go directly to http://www.divinesparkastrology.com/blogdsa it says Nothing Found.
I want http://www.divinesparkastrology.com/blogdsa and all of its subfolders and files to point to their new location at http://www.priestessastrology.com/ (the directory structure hasn't ever changed, only the base URL changed). How do I update the .htaccess file so that the new url still works properly, but if and only if the user has entered the old URL they are forwarded to the new one?
Edit: here's what's currently in my /dsa .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^divinesparkastrology\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.divinesparkastrology\.com$
RewriteRule ^/?$ "http\:\/\/www\.priestessastrology\.com\/" [R=301,L]
And here's what's in my /dsa/blogdsa .htaccess file:
# 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
Add the following RewriteRule to the WordPress .htaccess file:
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# added line
RewriteRule ^blogdsa/?$ / [R=301,L]
RewriteRule ^blogdsa/(.+)$ /$1 [R=301,L]
RewriteRule . /index.php [L]
Note: that you will never be able to access a blogdsa WordPress page with this rule in place.
Don't do it at the .htaccess level. Do it at the httpd.conf level, with a very basic
NameVirtualHost x.x.x.x
<VirtualHost x.x.x.x>
ServerName www.divinesparkastrology.com
ServerAlias divinesparkastrology.com *.divinesparkastrology.com
RedirectPermanent / http://priestessastrology.com
</VirtualHost>
This way you can do your redirects without having to mess with sharing .htaccess with wordpress or having the two sites sharing a common structure. Apache will take care of redirecting all requests to the new server name without having to load/parse/rewrite the .htaccess file on every single hit.
Add the following to your the top of your .htaccess file in the public_html/priestessentrepreneur/dsa/blogdsa folder. before any existing rules.
RewriteEngine On
RewriteBase /
#if request is on the divinesparkastrology domain
RewriteCond %{HTTP_HOST} ^(www\.)?divinesparkastrology\.com [NC]
#and it is for a folder starting with blogdsa
RewriteCond %{REQUEST_URI} ^/(blogdsa.*)$ [NC]
#redirect them to the same folder on the priestressastrology site
RewriteRule .* http://www.priestessastrology.com/%1 [L,R=301]
Edit: modified to include just divinesparkastrology without www and, more importantly, since blogdsa is a part of both sites, the .htaccess should be placed in blogdsa directory, not the dsa dir.