i have a domain on ovh, and so i uploaded all the file via FTP,
but when i want to redirect www.example.com to https://www.example.com/file12345.html it creates a sort of loop which makes i end up on https://www.example.com/file12345.html/file12345.html/file12345.html/file12345.html/file12345.html/file12345.html/file12345.html etc.
I have tried both using the ovh redirection rules and adding an .htaccess file in the root folder with the following code :
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ https://www.example.com/file12345.html$1 [R=301,L]
The problem remains the same. Do you have any solution to that ?
Related
I need help with a redirect rule.
I created a subdomain sub.abc.com and set it's public_html to that of abc.com.
This means public_html is now accessible either by abc.com or by sub.abc.com .
I want to limit this so that sub.abc.com only provides access to images in wp-content/uploads any other requests to sub.abc.com should be redirected to abc.com/url/url .
Here is what i have tried creating
RewriteCond %{HTTP_HOST} ^cdn.example.com
RewriteCond %{REQUEST_URI} !^/wp-content/uploads/$1
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
so if the user is accessing cdn.example.com/wp-content/uploads/1/1/file.jpg then there is no redirect, but if they are trying to access cdn.example.com/post/post or cdn.example.com/anything-else then it will redirect to example.com/post/post or example.com/anything-else .
The following rule should work for you. Remember to put it at the of your htaccess or server.config file before others rules otherwise these rules may override it.
RewriteEngine on
#serve only images on abc.example.com
#redirect to main domain if request is not for images
######################
#if the host is "sub.example.com"
RewriteCond %{HTTP_HOST} ^sub\.example\.com$ [NC]
#and the request is not for images and /wp-content/uploads
RewriteCond %{REQUEST_URI} !/wp-content/uploads/?$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpg|png|gif|jpeg)$ [NC]
#redirect the request to main domain
RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=302]
This will redirect your sub.example.com with request string to example.com if the subdomain is used for requests other then images .
Replace sub.example.com and example.com with your real domain name in the RewriteCond and RewriteRule above.
If this works and you are happy with the redirect then change R=302 to R=301 to make the redirection permanent.
I do expirience the following problem.
I do have a TYPO3 v7.6 CMS with multiple websites.
The problem is, that all files are visible in fileadmin if written in URL
For example PDF File with link
www.webpage-one.com/fileadmin/webpage-one/documents/pdffile
will be opened in browser if you type another URL of a webpage inside the same TYPO3 Instance.
www.webpage-two.com/fileadmin/webpage-two/documents/pdffile
Anyone with expirience on the matter?
Cheers
If you're using Apache (or another webserver that supports .htaccess and mod_rewrite) you can add a .htaccess file to the different directories in fileadmin with the following:
RewriteEngine On
RewriteCond %{HTTP_HOST} !webpage-one.com$ [NC]
RewriteRule ^ - [L,F]
This will make this directory only accessible from domains containing webpage-one.com. Other domains will get a 403 Forbidden error.
If it should only work for www.webpage-one.com (so not without www), you should change the RewriteCond line to:
RewriteCond %{HTTP_HOST} !^www.webpage-one.com$ [NC]
If it should work both with and without www, but not on other subdomains, you should use 2 RewriteCond lines:
RewriteCond %{HTTP_HOST} !^webpage-one.com$ [NC]
RewriteCond %{HTTP_HOST} !^www.webpage-one.com$ [NC]
Until 9.5 i used sys_domain for redirecting Domains.
For example: I had a Domain example.com and set a redirect to example.info.
When a user called example.com/contact it redirected to example.info/contact.
Now, with TYPO3 9.5, it won't work anymore. When setting up a redirect for this domain (sourcepath: /, Respect get: no, REGEX: no) and calls example.com/contact it throws an error.
When change the setting to regex: yes & source path (.*?), it just redircts to example.info - contact is forgotten.
Is there a way to get the 'old' functionality back?
It is not possible to automatically prepend the source path to the destination with the redirects module. Just redirect such domains via .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [or]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*) https://example.info/$1 [L,R=301]
I'm experiencing an infinite redirect loop when I try to access my site. The redirect loop seems to be between the non-www version and the www version.
My DNS has a URL Redirect set for http://domain.tld to www.domain.tld. Then www.domain.tld has a CNAME record for app-namespace.rhcloud.com.
For the app I added the alias www.domain.tld
I've also tried to add an alias for domain.tld, but that doesn't help.
Is there something I'm missing? Thank you very much for your help!
I'm hosting a laravel 5 project on openshift. www and non-www are tricky but I finally got it working with a simple 2 part solution...
since you can't use non-www for a cname, make it an A-record to 174.129.25.170 and they will add the www. That's all they seem to do. Weird, I know.
Use this in your .htaccess It seems to work better in cloud situations.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I found the issue. It was due to a redirect from www.domain.tld to domain.tld that was caused by a rewrite rule in the .htaccess file:
<IfModule mod_rewrite.c>
#RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>
Removing this resolved the issue.
I've built a new site for our company, whom I recently started working for, and deployed it on a separate subdomain (http://site.mysite.com) to not interfere with some URLs that need to remain on the old subdomain.
The old HTML site (http://www.mysite.co/site) was, for some weird reason, placed inside the public/ folder of a Zend application, as public/site. We want to redirect this site, which used to be available on http://mysite.com/site folder, to our new site at http://site.mysite.com
I've edited the existing .htaccess file, inside the Zend public folder so it looks like such:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,NC,L]
# These four lines are my only alterations to this file...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(apps|site).* [NC]
RewriteRule .* http://site.mysite.com/ [R=301,L]**
RewriteRule ^cart/selectaddress$ https://%{SERVER_NAME}/cart/selectaddress [R,L]
Redirect 301 /photobook-sa http://www.mysite.com/photobooksa/
Redirect 301 /photobook-SA http://www.mysite.com/photobooksa/
Redirect 301 /photobookSA http://www.mysite.com/photobooksa/
RewriteRule ^channel\.html channel\.php
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
php_value session.auto_start 0
RewriteRule ^.*$ index.php [NC,L]
Header append P3P "CP=\"HONK IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA\""
AddDefaultCharset UTF-8
The idea is to trap http://mysite.com/apps/, http://mysite.com/apps/whatever and http://mysite.com/site/ and redirect these all, unconditionally to http://site.mysite.com
The problem is, the redirection only works for /apps and apps/whatever, not for /site. So I discovered the public/site folder, which strangely hosts the company site as a HTML only site, within a Zend project folder structure.
Problem is, when I delete this folder, the whole mysite.com and www.mysite.com domain fails, but for example mysite.com/apps still manages to redirect to site.mysite.com
So I tried editing public/site/index.php to look as follows:
<?php
header('Location: http://site.mysite.com'); exit;
and it works, but only for a few requests, then I get a server error.
I also tried adding a .htaccess inside public/site/.htaccess with the following:
Redirect 301 http://site.mysite.com
which also, works initially, but then fails with a server error after a few requests?
I have no idea what's up, no clue as to why the virtual host is dependant on the public/site folder to work, which not even mentioned in the virtual host setups.
I grepped all the controllers in the Zend application/controllers folder to try and see if I can find anything that remotely mentions this /site folder, but no matches found.
I'm pulling the hair out of my scalp with this strange behaviour, can someone please help?
Also last point, this is an Amason AWS server, which I'm not entirely familiar with, could it be that this server has something funny going on, that's non-standard in terms of Apache configuration, DNS setup or something mysteriously automagic?
We've not been able to resolve this issue, and unable to figure out why our methods work only for a few minutes. I'm suspecting something weird happening with Amazon AWS.
The only way we could fix, was by adding an index.html inside the culprit /site folder, using a small JavaScript snippet to redirect the site from the client side.