I'm working on a Drupal website, in which I want to display my website as www.ex.com instead ex.com/drupal
I have tried using this code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^202.158.43.33$ [NC]
RewriteRule .* 202.158.43.33 [L,R=301]
RewriteRule ^$ drupal/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/drupal%{REQUEST_URI} -f
RewriteRule .* drupal/$0 [L]
RewriteCond %{REQUEST_FILENAME} ! -f
RewriteCond %{REQUEST_FILENAME} ! -d
RewriteRule .* drupal/index.php?q=$0 [QSA]
</IfModule>
which is saved in root folder and I have changed the $base_url = 'http://www.ex.com'; in drupal/sites/default/settings.php
When I run my website, I see the url as: 202.158.43.33/202.158.43.33/202.158.43.33/202.158.43.33.........
Could someone tell me how to fix this problem.
Instead of writing your own code, use Drupal's default .htaccess file. Then uncomment the last two lines of this snippet of code.
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Virtual host file Configuration:
<VirtualHost *:80>
ServerAdmin me#mysite.com
DocumentRoot "/var/www/http/mysite.com"
ServerName mysite.com
ServerAlias www.mysite.com
</VirtualHost>
The document root should point to the Drupal you're navigating to under your current site, the "/drupal" subdirectory.
Do you NEED drupal files to be on separate folder in this domain? I'm just asking because there is the obvious answer to make one's drupal site run in root directory: Just move all files from drupal folder (all the files that are located into "drupal" folder) to the parent (root) directory and your site will display on www.yourdomain.com, rather than on www.yourdomain.com/drupal
Related
I have a subdirectory (app) I want to access that is in the root folder of my wordpress site. I have looked here:
https://wordpress.stackexchange.com/questions/20152/cannot-access-non-wordpress-subdirectories-as-wordpress-overrides-them-with-a-40
I have tried the solutions and nothing worked.
I also tried adding a separate .htaccess file to the app subdirectory that looks like this:
DirectoryIndex index.php index.html index.htm
Options +Indexes
But it didn't seem to help:
The main .htaccess I am trying with now looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/app/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
# 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
I get a 404 error.
What am I doing wrong? If I am viewing the site on an iPhone, is clearing the safari history on the phone enough to refresh the data so it recognizes the new .htaccess? Thanks.
UPDATE
I added:
<Directory "/home/eamondev/public_html/subconscious/">
Options All
AllowOverride All
Require all granted
</Directory>
to a .conf file that gets Includeed in httpd.conf, restarted apache, but didn't help.
I also tried:
<Directory "/home/eamondev/public_html/subconscious/">
AllowOverride All
</Directory>
and it didn't work, I'm not sure if I only need AllowOverride All - either way this doesn't seem to help.
UPDATE
In a .conf file that is Included in httpd.conf, I tried:
<VirtualHost 162.241.180.99:80>
ServerName eamondev.com
DocumentRoot /home/eamondev/public_html
<Directory "/home/eamondev/public_html/">
AllowOverride All
</Directory>
</VirtualHost>
but it didn't help.
Is there any reason I shouldn't just make another subdomain on my server and host the files out of there so reaching them doesn't conflict with my wordpress site?
Use below code i think it will work.
<IfModule mod_rewrite.c>
RewriteEngine On
# Map http://www.example.com to /app.
RewriteRule ^$ /app/ [L]
# Map http://www.example.com/x to /app/x unless there is a x in the web root.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/app/
RewriteRule ^(.*)$ /app/$1
# Add trailing slash to directories within app
# This does not expose the internal URL.
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^app/(.*[^/])$ http://www.example.com/$1/ [R=301]
</IfModule>
Turns out, my domain hadn't propagated yet, so it wasn't possible to see/test any of the changes I was making. Before I realized that it was still propagating, I also thought to just create another subdomain and host the files I needed to from there.
I set my site up so that the root domain (flippinghousesforrookies.com) redirects to another site, but now the folders (flippinghousesforrookies.com/blog for example) I set up are also redirecting to the other site instead of their own index.php.
Any inside pages of the folders (flippinghousesforrookies.com/blog/contact for example) work fine, but not the homepage of each folder.
Not that I think it matters, but the site is set up as an add-on domain in it's hosting and each folder has a Wordpress install.
Here's the root's .htaccess:
RewriteOptions inherit
RewriteEngine on
#RewriteOptions inherit
# To set your custom php.ini, add the following line to this file:
# suphp_configpath /home/yourusername/path/to/php.ini
# php_value mbstring.func_overload 4 # Required for PWSB support. Please do not uncomment this line.
RewriteCond %{HTTP_HOST} ^flippinghousesforrookies\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.flippinghousesforrookies\.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "https\:\/\/flippinghousesforrookies\.mykajabi\.com\/" [R=301,L]
And here is one of the folder's .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Any help would be appreciated! Thanks!
The code you used in your root .htaccess file is too long for the purpose you are trying to do.
You can do this in two ways.
a)
In the root .htaccess file put this code instead of the one you were entering:
RewriteCond %{REQUEST_URI} !^/blog
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) https://flippinghousesforrookies.mykajabi.com/$1 [R=301,L]
This code checks if there is /blog in the URL. If it is, then this rewrite rule will not be met and therefore it will not redirect the visitor to the new page. If there is nothing behind the url (so no subfolders) then the visitor will be redirected to the new page.
b) You can use only this part of the code. It redirects only the root folder to the new domain and it leaves all subfolders as they are.
RedirectMatch 301 ^/$ http://example2.com/
P.S. - Both work, but I added both solutions so you can adapt it to your own taste.
whenever i try to run my project i get the folder structure only.Why?
Index of /my_project
Parent Directory
README.md
bin/
composer.json
composer.lock
vendor/
web/
Apache/2.4.7 (Ubuntu) Server at localhost Port 80
You need to configure your .htaccess or httpd.conf to access the web folder
Solution #1:
Create a .htaccess file with the following file-contents in the DocumentRoot folder (basically the place where you see this folder structure)
Options +FollowSymLinks +ExecCGI
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
RewriteBase /web
# we skip all files with .something
RewriteCond %{REQUEST_URI} \..+$
RewriteCond %{REQUEST_URI} !\.html$
RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ app.php [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
Solution #2:
You can also adjust the httpd.conf depending on your web-hosting provider, if that's the case I would consult this page on symfony: http://symfony.com/doc/current/setup/web_server_configuration.html
Update:
Please mark this question as answered if it answered your question
I put WordPress' configuration into my VirtualHost directive, it looks like this:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/html
<Directory />
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</Directory>
</VirtualHost>
When I put WordPress' configuration inside VirtualHost's root directory like above, the permalink and sub domain won't work.
But when I put WordPress' configuration inside the /etc/httpd/conf/httpd.conf root directory which is /var/www/html (as you can see it is the same root as Virtual host), then subdomain and permalinks are fine, I don't get it?
The reason I don't want to put WordPress' configuration in httpd.conf is because I want to make another site but it's not multisite, so I have to enter another WordPress' configuration on it.
I IncludeOptional the virtual host conf file at the very bottom of httpd.conf
I use CentOS 7
Apache 2.4
Wordpress 4.5.3
Mod rewrite included
After few hours it seems another rewrite rule that came above the IncludeOptional path/to/virtualhost/*.conf in httpd.conf had interfere Wordpress' configuration.
To troubleshoot most common permalinks or subdomains problem in wordpress is always check your rewrite rules and make sure the Wordpress rule (that one for the .htaccess) is always on top of the others.
What I'm trying to do is server a subfolder: /subsites/brighton/ when the url domain.com/pop-up-in-brighton/availability is visited (that url is/can be a WP page. Doesn't matter to me). The site is build on wordpress so that domain is itself the result of an apache rewrite.
I've looked at RewriteRule examples and tried to adapt them but failed miserably. Can anyone help?
Whether it needs to be a rewriterule or maybe an alias? It's shared hosting so only really have access to the htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/pop-up-in-brighton/availability /subsites/brighton
RewriteRule . /index.php [L]
</IfModule>
Thanks!
i think what you need to check is the virtual server directive, you can create a new website with it's own folder and IP.
<VirtualHost 10.20.30.1:80>
ServerAdmin webmaster#host.example.com
DocumentRoot /www/docs/host.example.com
ServerName host.example.com
ErrorLog logs/host.example.com-error_log
TransferLog logs/host.example.com-access_log
</VirtualHost>
Virtual server directive
also check this article about virtual hosts and .htaccess
.htacess and VH
You need to install wordpress in your sub directory /subsites/brighton and you can follow these instructions for using a sub directory.
http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
Then you can point to that directory from /pop-up-in-brighton/availability using mod_rewrite in the .htaccess of you root directory.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com$
RewriteCond %{REQUEST_URI} ^/pop-up-in-brighton/availability [NC]
RewriteRule ^(.*)/?$ /subsites/brigton [L]
See how that works. Replace yourdomain with your real domain.