Hi i need to use this existing htaccess located on the root folder.
I now need to create a new directory /testfolder/ to become http://www.companydomain.com/testfolder/ where all the files of the root will be located.
How can I make this happen with this existing htaccess? Much appreciated your help in advance!
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !(.*)/(.*).html$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]
# 301
RewriteCond %{HTTP_HOST} !^www\.companydomain\.com$ [NC]
RewriteRule .? http://www.companydomain.com%{REQUEST_URI} [R=301,L]
RewriteRule ^Sportsbooks\/(.*).html$ Sportsbooks\/$1\/ [R=301,L]
This .htaccess file will redirect http://example.com/file.html to http://example.com/folder1/file.html:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} example.com$ [NC]
RewriteCond %{HTTP_HOST} !folder1
RewriteRule ^(.*)$ http://example.com/folder1/$1 [R=301,L]
I hope this helps!
Related
I have a htaccess file in root and another htaccess in films folder. I want to stop all the rewrite urls or conditions to affect the films folder. I have some other rules in film folder htaccess.
My root htaccess looks like this
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^abc\.in$ [NC]
RewriteRule ^(.*)$ http://www.abc.in/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
My sub directory films folder htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /films/
RewriteCond %{REQUEST_METHOD} =POST
RewriteRule ^ - [L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteRule ^change-password/$ changepassword.php
RewriteRule ^change-password$ changepassword.php
The above code is just a glimpse of my original htaccess
You can do it by following code :-
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/films/$1 [R=301,L]
It may help you.
In /films/.htaccess ,Change your rule
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
to this :
RewriteRule ^(.*)$ http://%1/films/$1 [R=301,L]
To redirect all /films requests to www, you can use something like the following :
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
I have .htaccess files on every subfolder in demo.mydomain.net to redirect to mydomain.net without redirecting image/js files.
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/load
RewriteRule ^/?$ "http\:\/\/mydomain\.net" [R=301,L]
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/load/images
RewriteRule ^/?$ "http\:\/\/mydomain\.net" [R=301,L]
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/load/scripts
RewriteRule ^/?$ "http\:\/\/mydomain\.net" [R=301,L]
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/load/styles
RewriteRule ^/?$ "http\:\/\/mydomain\.net" [R=301,L]
Is there any way I can combine these to a single working file and save it to where my index file is?
You would need the following combined rule within the .htaccess in your directory mapped to demo.mydomain.net
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/load(/(images|scripts|styles))? [NC]
RewriteRule ^ http://mydomain.net [R=301,L]
The above %{REQUEST_URI} regex intercepts all four URL paths.
I am trying to keep my main domain structure from being too cluttered so I am parsing all of my domains into their own subfolder. So, what I am trying to do is when a user goes to http://mydomain.com they are actually sent to http://mydomain.com/sub-directory
This bit of code works:
#redirect to submain subdomain
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /submain/
RewriteRule ^submain/(.*) /$1 [L,R=301]
RewriteRule !^submain/ submain%{REQUEST_URI} [L]
However it breaks all the other subdomains I have loaded into my main directory.
Any ideas on how to fix this?
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /submain/
RewriteCond %{HTTP_HOST} ^(www\.)?domain.com$
RewriteRule ^submain/(.*) /$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?domain.com$
RewriteRule !^submain/ submain%{REQUEST_URI} [L]
Create a .htaccess file in root folder, and put this content inside(just change example.com and my_subdir):
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/my_subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /my_subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ my_subdir/index.php [L]
</IfModule>
I'm using rewrite rules for search engine optimized url's
In my root folder I have the following .htaccess file:
Options +FollowSymlinks RewriteEngine On RewriteCond %{http_host} ^elitegameservers.net [NC]
RewriteRule ^(.*)$ http://www.elitegameservers.net/$1 [R=301,L]
rewriteEngine on
rewriteBase /
rewriteCond %{HTTP_HOST} ^(.*)haloservers(.nl|.us|.net)$
rewriteRule ^(.*) http://www.haloservers.net/$1 [L,R=301]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?haloservers(.nl|.us|.net) [NC]
RewriteRule ^(.*)\.html$ http://www.elitegameservers.net/$1 [R=301,L]
In the sub directory(/controlpanel) I run WHMCS with the following .htaccess file:
RewriteEngine On
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^elitegameservers.net [NC]
RewriteRule ^(.*)$ http://www.elitegameservers.net/controlpanel/$1 [R=301,L]
RewriteEngine On
# Announcements
RewriteRule ^announcements/([0-9]+)/[a-z0-9_-]+\.html$ ./announcements.php?id=$1 [L,NC]
RewriteRule ^announcements$ ./announcements.php [L,NC]
# Downloads
RewriteRule ^downloads/([0-9]+)/([^/]*)$ ./downloads.php?action=displaycat&catid=$1 [L,NC]
RewriteRule ^downloads$ ./downloads.php [L,NC]
# Knowledgebase
RewriteRule ^knowledgebase/([0-9]+)/[a-z0-9_-]+\.html$ ./knowledgebase.php?action=displayarticle&id=$1 [L,NC]
RewriteRule ^knowledgebase/([0-9]+)/([^/]*)$ ./knowledgebase.php?action=displaycat&catid=$1 [L,NC]
RewriteRule ^knowledgebase$ ./knowledgebase.php [L,NC]
I noticed that knowledgeable SEO optimization in WHMCS doesn't seem to work properly and it seems to be caused by the .htaccess code in my root directory.
Because of that I want the controlpanel sub directory to be excluded from the code in the root directory.
Thanks for any help
You could try adding a condition to the rules in your root directory to exclude requests starting with controlpanel:
RewriteCond %{REQUEST_URI} !^/controlpanel
rewriteCond %{HTTP_HOST} ^(.*)haloservers(.nl|.us|.net)$
rewriteRule ^(.*) http://www.haloservers.net/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !^/controlpanel
RewriteCond %{HTTP_HOST} ^(www\.)?haloservers(.nl|.us|.net) [NC]
RewriteRule ^(.*)\.html$ http://www.elitegameservers.net/$1 [R=301,L]
I have created a website using IPB which I believe is written in PHP, the URL is the forum at present is
what I would like is the URL to be rewritten to
and when user go to the index for force user to use instead of
any help with be greatly appreciated!
Make sure mod_rewrite is enabled and AllowOverride All is set in your conf file, and put these rules in the .htaccess file in the root of your web directory:
RewriteCond %{HTTP_HOST} !^www
RewriteRule ^(.*)$ http://www.thereviewforum.com/$1 [R]
RewriteCond %{HTTP_HOST} ^thereviewforum
RewriteRule ^forum(.*) http://community.thereviewforum.com$1 [R,L]
EDIT with full .htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^thereviewforum.com
RewriteRule ^(.*)$ http://www.thereviewforum.com/$1 [R]
RewriteCond %{HTTP_HOST} ^www.thereviewforum
RewriteRule ^forum/?(.*) http://community.thereviewforum.com/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !.*\.(jpeg|jpg|gif|png|ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]