301 Redirect from subdomain to URL - mod-rewrite

I'm trying to set up a 301 redirect from a subdomain to a facebook page. I'm using this below and have uploaded it to the root folder on the server. I've also tried to upload this to the subfolder (example.com/blog), but to no avail...
RewriteEngine on
RewriteCond %{HTTP_HOST} ^blog.example.co.uk
RewriteRule ^(.*)$ http://www.facebook.com/example/$1 [R=301,L]
#Deny access to htaccess
Order Allow,Deny
Deny from all
Does anyone have any ideas why this isn't working?
Thanks in advance,
Ash
NOTE:
I've investigated this a little further and forgot to mention that the subdomain is set up on an old version of Drupal. This causes the site to fail when we set up any subdomain.
We can still navigate to the folder that the subdomain uses and the redirect works fine there.
So, the issue seems to be with drupal and subdomains, not the redirect.
Thanks,
Ash

What kind of error are you getting?
This bit of code would deny access to everything, not just .htaccess like it states in the comments...
#Deny access to htaccess
Order Allow,Deny
Deny from all

Related

Why redirecting http:// to https:// in go daddy doesn't working?

Today I installed the SSL certificate in my GoDaddy hosting account.
Everything seems to work when I type "https://myDomain.co.il, meaning, my website is secured.
But when I type HTTP://myDomain.co.il, my website is not secured.
As I was looking for an answer to solve this problem, I found an article in GoDaddy that explains how to redirect HTTP to https.
Is says that I need to open a file inside public_html called .htaccess.
Inside the file, I wrote the following code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?coolexample\.com
RewriteRule ^(.*)$ https://www.coolexample.com/$1 [R,L]
Unfortunately, it's not working.
Another question, when I'll solve this problem, if I will type www.myDomain.co.il or myDoamin.co.il, will it redirect to https as well?

Remove /Public from url in Laravel

Good Day!
Hello,
Currently I was working on laravel and im new on it. I keep looking a solutions on my problem and i couldn’t find a solution on this. My laravel work is accessible already without /public in the url I fix this thru .htaccess, but it can be access also with /public in the url. Please see links below for your reference.
https://utok.ph/
https://utok.ph/public
my htaccess file
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
.htaccess files wont work on this, what i did is i update the root directory in my server side.
instead the root will be at public_html I change it to public_html/public

URL redirects to hompage when typed without www

Having a small issue with my website, any help would be very appreciated.
If I type a url such as website.com/feedback
It redirects to the homepage.
But typing www.website.com/feedback
It goes to the page as I want it to.
From Googling, I understand this is a .htaccess issue - but I'm a little unsure of what code to add or change. I'm find with the website displaying as www.website.com in the address bar - so I think I need to redirect non-www. urls to www. urls ?
I'm using Magento.
So the problem is that Magento is not keeping the path, i. e. /feedback but sending you to the homepage instead when calling the non-WWW version of your site.
You could add this to your .htaccess
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
It redirect all non-WWW requests to WWW request while keeping the path/sub page originally called.

How to rewrite URL PrestaShop to hide folder?

I would like to hide my folder where PrestaShop is installed.
To access my shop, I must write http://domain.com/prestashop.
But I want access to my shop like this: http://domain.com.
How can I do this?
If you don't have access to your server configuration.
Add this .htaccess to your / directory.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/Prestashop/.*$
RewriteRule ^(.*)$ /Prestashop/$1 [L]
</IfModule>
Don't forget to change your shop_url in SEO / URL.
You must point your domain name to a specific subfolder.
If you point domain.com on prestashop subfolder then you should change it in your back office:
Preferences -> SEO & URLs
After the change you should disable Friendly URL and then enable it again - Enabling Friendly URL generates .htaccess

Magento Godaddy No file input specified

I have Linux webhosting on Godaddy. I tried installing Magento CE 1.8 on subdomain for more than a week and I still cannot get it to work.
Before you say this question is duplicit, I have tried everything I found on Magento Wiki, Forums, Google and Godaddy forum and support and I still cannot get it to work.
For php5.ini I take Magento php.ini.sample, .htaccess is from Magento too.
Using Options -MultiViews in .htaccess usually doesn't do anything.
Settings cgi.fix_pathinfo = 1 in php5.ini creates cyclic redirect.
I have tried playing with RewriteBase in .htaccess and that didnt help either.
I read that Magento doesnt run on fcgi, so I use in my .htaccess, doesnt help either:
Options +ExecCGI
addhandler x-httpd-php5-cgi .php
I always end up with "No file input specified" or cyclic redirect or server error.
Only lines in error log that I see are added:
[Thu Oct 31 01:23:08 2013] [11988011] [negotiation:error] [client 5.178.58.85:65433] AH00687: Negotiation: discovered file(s) matching request: "path" (None could be negotiated).
But I dont know what that does mean or how to fix that.
So is there anything else I can try or am I missing something? I know Magento on Godaddy shared hosting isnt a good idea, but I need to get there my development running and production will run on my clients Dedicated server.
Add this to your .htaccess file and forgot those other fixes....
RewriteRule ^index.php/(.*)$ [L]
If magento lies in a subdirectory then use:
RewriteRule ^index.php/admin(.*) {RewriteBase}/admin$1 [L]
So I managed to solve it after few weeks of trying different solutions on net and trying to get support to help me.
Nothing helped solve it so I tried myself and found out that the problem is "index.php" in url. So I have created simple php function which is run in at the beginning of index.php file. This function removes "index.php/" from url and redirects to this new url.
Also to remove "index.php" from form actions and other places where the url might show up, it is good to create your own router module or modify Magentos router.
Now it all works.
PS:
I have also kept other fixes in place:
In .htaccess:
Options +ExecCGI
AddHandler x-httpd-php5-cgi .php
AddHandler x-httpd-php5-cgi .php5
Options -MultiViews
RewriteBase /
And in php5.ini
cgi.fix_pathinfo = 1
EDIT
What I wrote does work, but is not good solution, redirect in index.php loses all POST data ofcourse. And looking at Magento and changing router takes too much work, so in the end I managed to create working rule in .htaccess for admin. Just put it as last rewrite rule in your .htaccess:
RewriteRule ^index.php/admin(.*) /admin$1 [L]
EDIT
Forgot to write here, that I have changed the rewrite to this:
RewriteRule ^index.php/(.*) /$1 [L]

Resources