301 apache redirect non existing path using .htaccess joomla - apache

I want to redirect a path: /folder/filename.html to: /folder/newfolder.
My host says I must create a dummy file at /folder/filename.html or it won't redirect. I can't do this as by creating the /folder, that messes up Joomla which would normally create that part of the path dynamically. I'm not sure I believe my host, surely it's possible to redirect a path regardless whether there is a file there?

In your .htaccess after RewriteEngine On just add this line
RewriteRule ^/folder/filename.html /folder/newfolder/filename.html [R=301,L]

Related

Redirect sub-folder to another folder

I need to redirect the content of domain.com/app1 to domain.com/apps/app1, but keep the url domain.com/app1.
How to do that?
Is it possible to do via .htaccess file, or should I modify httpd.conf file, add some VirtualHost ...?
Thanks.
You can use this rule in http or virtual host config:
RewriteEngine On
RewriteRule ^/?app1(/.*)?$ /apps%{REQUEST_URI} [L,NC]
You may use this rule in site root .htaccess as well.

apache2 .htaccess redirect subdirectory to domain without including path

I am attempting to redirect a subfolder on an apache2 server to the root of an entirely different domain, without including the path of the folder in the new domain.
So, in mysite.com/folder-1/folder-2 I have a .htaccess file like so:
RedirectMatch 301 / http://a-totally-different-site.com/
This sort of works, but includes the path in the redirect. So, when you visit mysite.com/folder-1/folder-2 it goes to a-totally-different-site.com/folder-1/folder-2
What I wish to happen, is for the subfolder to redirect to the root, so visiting mysite.com/folder-1/folder-2 will go to a-totally-different-site.com
Is this possible with .htaccess? I have tried a few different approaches I found, but none are working.
Simple rewrite rule should do:
RewriteEngine On
RewriteRule ^ http://a-totally-different-site.com [R=301]

htaccess Multiple domains in one root running different phps

I am trying to set up an .HTACCESS so I can have multiple domains with the same root directory. I want the htaccess to redirect to a php file dependant on domain name. I don't want to have to set it up per domain - I want it to be for any domain that I set up with the common root directory to redirect to its own php of the same name. eg
mydom1.co.uk will direct to mydom1.php ,
another.co.uk will direct to another.php
thanks in advance for any help
You can put the following in your .htaccess file at the document root:
RewriteEngine On
RewriteBase /
RewriteRule .* %{HTTP_HOST}.php [L,QSA]
However, I expect you'll need to amend the main rule to handle the request of different pages. At the moment everything will be rewritten to /domain.php

.htaccess redirect domain to folder

I have several domain names that point to the same IP address. I currently redirect them from the /default.asp file to the appropriate folder based on the SERVER_NAME. For example:
http://domain1.com redirects to http://domain1.com/folder1
http://domain2.com redirects to http://domain1.com/folder2
This works, but the urls display the folder name in the browser:
http://domain1.com/folder1/somepage.htm
And the user can't go to a page without entering the folder name:
http://domain1.com/somepage.htm // This fails because it isn't in the root folder.
Can I use the .htaccess file to (1) route page requests to the appropriate folder and (2) prevent the folder name from appearing in the browser?
That'd also move the redirection from the /default.asp file to the .htaccess file where it probably belongs.
Thanks!
RewriteEngine on
RewriteMap lowercase int:tolower
RewriteCond %{lowercase:%{HTTP_HOST}} ^www\.([^.]+)\.example\.com$
RewriteRule ^(.*) /home/%1/www$1

301 redirect not working

I made a subdomain, and I am trying to redirect a page from the original domain to the subdomain, with the same dir structure.
My original page is this:
http://www.comehike.com/outdoors/alaska_hiking.php
I put this rule into the .htaaccess file under comehike.com/outdoors/ directory:
RewriteRule ^outdoors/alaska_hiking.php http://hiking.comehike.com/outdoors/alaska_hiking.php [R,L]
But as you can see from visiting the original url, it doesn't redirect. Any idea why?
Thanks!
I use apache server.
That RewriteRule line works for me when I stick it in my .htaccess file, are you sure you have RewriteEngine On?