How to change Temp URL - RHEL & Drupal 7 - drupal

RHEL, MySQL Drupal7, Apache
Drupal 7 showing links with /?q=node/, i have tried to Clean URLs, which has failed. I am changing in .htaccess drupal7 file but its not showing any effect. I have URL 1.1.1.1/drupal/?q=node/1 which i have to replace by 1.1.1.1/drupal/aboutus
Already enable
RewriteBase /drupal
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
NOTE -The clean URL test failed - Any help ?

Those rewrite rules you've got enabled are for redirecting non-www to www. Make sure you've got this rule in your .htaccess:
RewriteRule ^ index.php [L]

Related

Redirecting url to access subdirectory

I have a wordpress subdirectory install in a directory called 'wordpress'. So currently I am able to access the live site as follows: www.domain.com/wordpress.
My objective is for users to simply navigate to: www.domain.com, omitting the wordpress directory from the url.
I was wondering if someone can help me configure my .htaccess so every time a user navigates to anything with domain.com/wordpress it'll redirect to domain.com.
So for example: domain.com/wordpress/admin will become domain.com/admin
I created a new .htaccess file and placed in the root with the following contents, which did not work :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ wordpress [L]
To rewrite / to /wordpress you can use this rule :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain.com$
RewriteCond %{REQUEST_URI} !^/wordpress
RewriteRule ^(.*)$ /wordpress/$1 [L]
This will internally redirect all requests from root to the subfolder.
Do not remove the RewriteCond directive otherwise the the rewrite destination will rewrite back to itself causing an infinite loop error.

Redirect Joomla URLs (with index.php SEF links) to Wordpress Multisite (subdomain setup)

I relaunched a website that was originally created with Joomla, now using Wordpress for it (with subdomain multisite setup). The main domain remained the same.
Now I'm trying to redirect the old pages to the new ones via htaccess but it seems to cause a problem that the old URLs were formatted like "www.domain.com/index.php/de/oldpagename" because they seem to get stripped of index.php (and even the "/de/" oder "/en" parts) before the redirects are taking effect.
For example:
Redirect 301 /index.php/de/impressum http://de.domain.com/kontakt/
This leads to de.domain.com/impressum so the redirect is ignored but instead the URL is stripped of the index.php and there seems to be another redirect to the language subdomain based on the /de/ part.
I'm not very familiar with htaccess but my suspicion is that Wordpress' rewrite rules (and maybe a plugin - Multisite Language Switcher) are interfering here.
The only other code in the htaccess file is the Wordpress part:
# BEGIN WordPress
<IfModule mod_rewrite.c>
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]
</IfModule>
# END WordPress
I tried moving the redirects above the Wordpress rewrite rules in the file and leaving out "/index.php" in the redirects with both making no difference at all. I also tried the Redirection plugin without success.
Does anyone have a solution for this?
I've been searching the web and Stockoverflow for hours now but everything that sounded promising didn't match my scenario or involved dynamic Joomla URLs.
Thank you very much in advance!

https and http combined .htaccess (different issue)

OK. Hopefully someone can help me with a suggestion-
I have a WordPress multisite using subfolders
I am using WooCommerce
I have a std Ubuntu 12.04/LAMP server with a GoDaddy Certificate installed
If it turn on SSL, it affects my entire domain (obviously) so my primary site ends up as:
'https://main-sitename.com'
My multisite blogs also come up as:
https://main-sitename.com/blogname-1
https://main-sitename.com/blogname-2
and so on. ALL of my menu links are also https which disables outside links because the urls all get prepended with https. :-/
What I am trying to do is get this:
http://main-sitename.com
http://main-sitename.com/blogname-1
http://main-sitename.com/blogname-2
https://main-sitename.com/shop/ (WooCommerce will force HTTPS on checkout and then un-enforce it when done).
So, Anyone have any ideas on how I can remedy this? On an interesting note, when I had the EXACT same site on Rackspace Cloud Sites everything worked fine. When I moved to a self managed Cloudserver this happened. Is there something I missed?
It sounds like SSLRequireSSL has been set for the entire server. Since you only want to enforce HTTPS on /shop/ directory. Add a .htaccess file in that directory that contains:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This will force anyone connecting to your shop with http:// to be redirected to the same URI, but on https://
EDIT 2
This works for me (with www.myserver.com changed to my real server name). I'm using date and name permalinks in WP. As soon as I go to http://www.myserver.com/shop/ I'm redirected to https. It preserves the URI.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# Addition to force redirect to https when they visit the shop!
RewriteBase /
RewriteCond %{HTTPS} !on
RewriteRule (shop/.*$) https://www.myserver.com/$1 [R=301,L]
# Back to WordPress changes
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

mod_rewrite http_host

How can I prevent access to a subdirectory based on HTTP_HOST.
I have 2 parked domains pointing to one directory. They both serve up the same website.
However I wish each to have a seperate wordpress blog. To do this I'm installing them in different directories.
domain1.com/domain1-blog/
domain2.com/domain2-blog/
The trouble is the directories are accessible across domains. For instance
domain1.com/domain2-blog/
domain2.com/domain1-blog/
I REALLY don't want people to be able to access across domains. Wordpress will break and I will get duplicate content issues in Google.
What is the EXACT code I need to put into my htaccess file to serve up a 404 error should anyone try to access
domain1.com/domain2-blog/
OR
domain2.com/domain1-blog/
I thought maybe using HTTP_HOST combined with mod_rewrite somehow?
I'm a big newb when it comes to htaccess, so the more explicit you can be the better.
Thanks
Try adding the following to your htaccess file in the root directory of your domain
RewriteEngine on
RewriteBase /
#if its domain1
RewriteCond %{HTTP_HOST} domain1\.com$ [NC]
#and the request is for domain2 blog
RewriteCond %{REQUEST_URI} ^/domain2-blog/ [NC]
#send a 403 forbidden
RewriteRule . - [F,L]
#if its domain2
RewriteCond %{HTTP_HOST} domain2\.com$ [NC]
#and the request is for domain1 blog
RewriteCond %{REQUEST_URI} ^/domain1-blog/ [NC]
#send a 403 forbidden
RewriteRule . - [F,L]

Drupal Multisite in subfolders, www redirection in htaccess

I'm using a multisite setup in subfolders, everything works fine except the non-www to www redirection.
I got it working with no issues for the main domain, but I cant get it to work for the other sites:
for example , I want this redirection :
site.com/ru > www.site.com/ru
Try
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^site.com [nc]
rewriterule ^(.*)$ http://www.site.com/$1 [r=301,nc]
If you check .htaccess file you may see on 85-90 line (Drupal 7.x):
# 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} .
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
And if you uncomment this lines you may get solutions for your problem.
RedirectPermanent /ru http://www.site.com/ru
might be a better alternative to Rewrite rules.

Resources