Merge two .htaccess codes - apache

I have two .htaccess , the fist .htaccess locate in the root directory which is www folder and the 2nd .htaccess locate in folder called forum
the .htaccess codes in www folder cannot work with the .htaccess codes in the forum folder
what i am working on is how to merge both htaccess to be in the root directory www
.htaccess in the www directory
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.site\.com$
RewriteRule ^/?$ "http\:\/\/www\.site\.net\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^(?:www\.)?site\.com$ [NC]
RewriteRule ^(.*)$ http://www.site.net/$1 [R=301,L]
.htaccess in the forum directory
#RewriteEngine On
RewriteRule ^site-t(.*).html showthread.php?t=$1 [L]
RewriteRule ^site-f(.*) forumdisplay.php?f=$1 [L]
RewriteRule ^f(.*)-(.*).html forumdisplay.php?f=$1 [L]
RewriteRule ^site-u(.*).html member.php?u=$1 [L]
RewriteRule ^index.php$ http://%{http_host}/ [R=301,L
RewriteRule ^t(.*).html showthread.php?t=$1 [L]
RewriteRule ^f(.*).html forumdisplay.php?f=$1 [L]
RewriteRule ^post(.*)-(.*) showpost.php?p=$1&postcount=$2 [L]
RewriteRule ^u(.*).html member.php?u=$1 [L]
RewriteRule archive/t-(.*) archive/index.php/t-$1 [L]
RewriteRule tags/(.*).html tags.php?tag=$1 [L]
RewriteEngine on
# This file is only needed if you have set the Forum Component URL in your admincp and you are
# using the mod_rewrite option for friendly urls. If this is the case, copy this file
# to your forum component stub directory.
# If you are having problems or are using VirtualDocumentRoot, uncomment this line and set it to your forum component directory.
# RewriteBase /forum-stub-directory/
# If you are having problems with the rewrite from content/ to content.php, uncomment this line to turn MultiViews off.
# Options -MultiViews
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# Forum
RewriteRule ^threads/.* showthread.php [QSA]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^members/.* member.php [QSA]
##################################################
RewriteEngine on
RewriteRule ^f.txt vbmaps.php?cat=d [L]
RewriteRule ^t([0-9]+).txt vbmaps.php?rss=d&page=$1 [L]
RewriteRule ^tag([0-9]+).txt maptag.php?rss=d&page=$1 [L]
RewriteRule ^t([0-9]+).txt vbmaps.php?rss=d&page=$1 [L]
RewriteRule ^tag([0-9]+).txt maptag.php?rss=d&page=$1 [L]
RewriteRule ^forums maps.php?cat=d [L]
RewriteRule ^thread([0-9]+) maps.php?rss=d&page=$1 [L]
RewriteRule ^forums.xml maps.php?cat=d
RewriteRule ^thread([0-9]+).xml maps.php?rss=d&page=$1 [L]
RewriteRule ^t([0-9]+)\-([0-9]+)\.html$ showthread.php?t=$1&page=$2 [L]
RewriteRule ^f([0-9]+)\-([0-9]+)\.html$ forumdisplay.php?f=$1&page=$2 [L]
RewriteRule ^post([0-9]+)\.html$ showthread.php?p=$1#post$2 [L]
RewriteRule ^t(.*).html showthread.php?t=$1 [L]
RewriteRule ^u(.*).html member.php?u=$1 [L]
RewriteRule ^f(.*).html forumdisplay.php?f=$1 [L]
RewriteRule ^f(.*)-t(.*) showthread.php?t=$1 [L]
RewriteRule ^t([0-9]+)\-([0-9]+)$ showthread.php?t=$1&page=$2 [L]
RewriteRule ^f([0-9]+)\-([0-9]+)$ forumdisplay.php?f=$1&page=$2 [L]
RewriteRule ^post([0-9]+)$ showthread.php?p=$1#post$2 [L]
RewriteRule ^t([0-9]+)$ showthread.php?t=$1 [L]
RewriteRule ^u([0-9]+)$ member.php?u=$1 [L]
RewriteRule ^f([0-9]+)$ forumdisplay.php?f=$1 [L]
RewriteRule ^t([0-9]+)\-([0-9]+)$ showthread.php?t=$1&page=$2 [L]
RewriteRule ^f([0-9]+)\-([0-9]+)$ forumdisplay.php?f=$1&page=$2 [L]
RewriteRule ^post([0-9]+)$ showthread.php?p=$1#post$2 [L]
RewriteRule ^t([0-9]+)$ showthread.php?t=$1 [L]
RewriteRule ^u([0-9]+)$ member.php?u=$1 [L]
RewriteRule ^f([0-9]+)$ forumdisplay.php?f=$1 [L]
RewriteEngine On
RewriteRule ^t(.*).html showthread.php?t=$1 [L]
RewriteRule ^f(.*).html forumdisplay.php?f=$1 [L]
RewriteRule ^u(.*).html member.php?u=$1 [L]
RewriteRule ^(.*)-post(.*).html showpost.php?p=$1&postcount=$2 [L]
RedirectMatch 301 thread(.*).html$ http://www.site.net/vb/showthread.php?t=$1
#########################################################
RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbulletin_sitemap_index.xml.gz [L]

Related

.htaccess redirection with multiple subdomain/folder

I have three folders : the base (root like www) and 2 folders :pro / perso.
I have 2 subdomains : pro.mysite.com and perso.mysite.com
I want only one .htaccess, on root and i want to create redirection for both subdomains/folders.
Like if i write mysite.com/Pro/index.php?p=cake i want to be redirected on pro.mysite.com/cake
mysite.com/Pro to pro.mysite.com is OKAY by the hosting tools.
For the pages, i have big issues. Here's my htaccess :
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule /?Pro/cake /Pro/index.php?p=cake [L]
RewriteRule /?Perso/kitten /Perso/index.php?p=kitten[L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ / [L,R=301]
Actually its work but... Without knowing why, it removes my "index.php", if i go on : perso.mysite.com/kitten im redirected on : perso.mysite.com/?p=kitten
Here's my actual.htaccess :
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
Rewritecond %{HTTP_HOST} !^www\.example\.com
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
RewriteRule /?Pro/revue-presse-articles-sport-coach-alsace /Pro/index.php?p=presse [L]
RewriteRule /?Pro/cachier-des-charges-sport-entreprise-coaching /Pro/index.php?p=cahierCharges [L]
RewriteRule /?Pro/offre-coaching-sport-entreprise-alsace /Pro/index.php?p=offres [L]
RewriteRule /?Pro/contact-entreprise-pro-coaching-sportif-coach-sport-alsace /Pro/index.php?p=contact [L]
RewriteRule /?Pro/temoignages-coaching-entreprise-coach-societe-sport-alsace /Pro/index.php?p=temoignages [L]
RewriteRule /?Pro/activites-sportives-entreprise-pro-coaching-sportif /Pro/index.php?p=activites [L]
RewriteRule /?Pro/coaching-sport-entreprise-pro-coach-sportif-alsace /Pro/index.php?p=presentation [L]
RewriteRule /?Particulier/coaching-activites-sportives-particuliers /Particulier/index.php?p=activites [L]
RewriteRule /?Particulier/concept-coach-coaching-individuel-collectif-domicile /Particulier/index.php?p=concept [L]
RewriteRule /?Particulier/studio-sport-sante-alsace-apas /Particulier/index.php?p=studioSante [L]
RewriteRule /?Particulier/equipe-staff-membres /Particulier/index.php?p=equipe [L]
RewriteRule /?Particulier/cachier-des-charges-sport-particuliers-domicile-coaching /Particulier/index.php?p=cahierCharges [L]
RewriteRule /?Particulier/coaching-sportif-domicile-alsace-bas-rhin-haut-rhin-strasbourg /Particulier/index.php?p=couvertureGeo [L]
RewriteRule /?Particulier/offre-coaching-sport-domicile-alsace /Particulier/index.php?p=offre [L]
RewriteRule /?Particulier/tarifs-prix-offres-coaching-sportifs-sport-alsace /Particulier/index.php?p=tarifs [L]
RewriteRule /?Particulier/contact-coaching-sportif-domicile-coach-sport-alsace /Particulier/index.php?p=contact [L]
RewriteRule /?Particulier/temoignages-coaching-domicile-coach-sport-alsace /Particulier/index.php?p=temoignages [L]
RewriteRule /?Particulier/coaching-sport-domicile-coach-sportif-alsace /Particulier/index.php?p=presentation [L]
RewriteRule /?Particulier/nos-coachs-sportifs-domicile-coach-alsace /Particulier/index.php?p=coachs [L]
ErrorDocument 404 https://www.example.com
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ / [L,R=301]
So, if we take the first one, actually if i go on : pro.example.com/revue-presse-articles-sport-coach-alsace it redirect me on pro.example.com/?p=presse
My only wish is to be redirected on :
pro.example.com/revue-presse-articles-sport-coach-alsace (without seeing the true page index.php?blabla etc)
or pro.example.com/index.php?p=presse

Apache : one of my RewriteRules doesn't working

All of my RewriteRules runs fine except one: ^assets/(.*)$ site/assets/$1 [L]
Actually with this one I get a 404 error but my file is at the good place...
<script type="text/javascript" src="assets/js/script.js" ></script>
File in MAMP/website_name/site/assets/js/script.js
I tried different methods but nothing solve the problem.
The RewriteRule ^js/(.*) site/webroot/js/$1 [L] works well !
Here's my .htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^assets/(.*)$ site/assets/$1 [L]
RewriteRule fileXupload/server/php/$ fileXupload/server/php/index.php [L]
RewriteRule site/webroot/uploads$ http://signatix.local [R=301,L]
RewriteRule site/webroot/uploads/$ http://signatix.local [R=301,L]
RewriteRule fckeditor/(.*) externallibs/fckeditor/$1 [L]
RewriteRule ^img/(.*) site/webroot/img/$1 [L]
RewriteRule ^imgupload/(.*) site/webroot/imgupload/$1 [L]
RewriteRule ^js/(.*) site/webroot/js/$1 [L]
RewriteRule ^css/(.*) site/webroot/css/$1 [L]
RewriteRule ^upload/(.*) site/webroot/upload/$1 [L]
RewriteRule ^/img/(.*) site/webroot/img/$1 [L]
RewriteRule /upload/(.*) site/webroot/upload/$1 [L]
RewriteRule /upload.php site/upload.php [L]
RewriteRule /md5.php site/md5.php [L]
RewriteRule ^uploads/(.*) site/webroot/uploads/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([[:punct:]]?)(.+)$ index.php?url=$1&%{QUERY_STRING} [L]
#RewriteCond %{HTTP:HTTPS} !on
#RewriteRule (.*) http://%{SERVER_NAME}/$1 [QSA,L,R=301]
</IfModule>
I'm trying to get all of my RewriteRules working.

Apache .htaccess, subfolder

I have website on Phalcon and everything works fine (I have SSL) but now I would like to have an access to the forum (https://www.example.com/forum/) but I have a problem with the .htaccess configuration.
Phalcon have the specific config:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.example.com [NC]
RewriteRule ^(.*)$ http://www.example.com%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
What is the correct configuration for home domain and /forum/ folder?
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^ "http://www.example.com%{REQUEST_URI}" [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^ "https://%{SERVER_NAME}%{REQUEST_URI}" [R,L]
RewriteCond %{REQUEST_URI} !^/forum/
RewriteRule ^.*$ public/$0 [L]
Phalcon's root .htaccess file redirects all traffic to /public folder.
What you need to do is add one more condition to your final rewrite rule. Here is portion of my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
# Force www
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]
# Forward to public/
RewriteRule ^(forum)($|/) - [L]
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
This RewriteRule ^(forum)($|/) - [L] is the important condition you need to add before RewriteRule ^.*$ public/$0 [L]
Also you can add as much as rules you want to allow multiple folders.
RewriteRule ^(forum)($|/) - [L]
RewriteRule ^(some-other-folder)($|/) - [L]
...

Priority redirecting using .htaccess

I want to set a priority in my .htaccess.
Ok, I've got folders on my root project, schema:
-root:
-core
-includes
-pages:
- profile.php
-etc
-support
-infractions
-.htaccess
and what I want to do is:
If the URL is like https://example.com/support, show the /support/index.php.
I've tried -Indexes option but it doesn't works or doesn't meet my needs.
My .htaccess is like:
Options +FollowSymlinks
Options +Indexes
Options -MultiViews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^fenixcms\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://fenixcms.com/$1 [R,L]
RewriteBase /
DirectoryIndex pages/index.php
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^alert/([^/\.]+)/?$ pages/alert.php?id=$1 [L]
RewriteRule ^player/([^/\.]+)/?$ pages/profile.php?name=$1 [L]
RewriteRule ^forums/new_topic/([^/\.]+)/?$ /forums/new_topic.php?c=$1 [L]
RewriteRule ^forums/topics/([^/\.]+)/posts/edit/([^/\.]+)/?$ /forums/edit_post.php?tid=$1&pid=$2 [L]
RewriteRule ^forums/topics/([^/\.]+)/posts/new/?$ /forums/new_post.php?tid=$1 [L]
RewriteRule ^forums/topics/([^/\.]+)/posts/reply_to_id/([^/\.]+)/?$ /forums/new_quote.php?tid=$1&pid=$2 [L]
RewriteRule ^forums/topics/([^/\.]+)/edit/?$ /forums/edit_topic.php?tid=$1 [L]
RewriteRule ^forums/topics/([^/\.]+)/?$ /forums/topic.php?id=$1 [L]
RewriteRule ^forums/topics/([^/\.]+)/posts/delete/([^/\.]+)/?$ /forums/delete_post.php?tid=$1&pid=$2 [L]
RewriteRule ^forums/categories/([^/\.]+)/?$ /forums/categories.php?s=$1 [L]
RewriteRule ^forums/posts/([^/\.]+)/?$ /forums/posts.php?pid=$1 [L]
RewriteRule ^forums/([^/\.]+)/?$ /forums/$1.php [L]
RewriteRule ^revisions/([^/\.]+)/?$ pages/revisions.php?action=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)/([^/\.]+)/?$ /$1/$2.php [L]
RewriteRule ^([^\.]+)/?$ /$1/index.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ pages/$1.php [NC,L]

redirect all non www to www. for Cakephp site

Hi allm i'm having some issues in redirecting the non www pages to the www. pages for my cakephp site.
I've tried
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
but it doesn't seem to work.
My cakephp app resides in a subfolder. eg. www.domain.com/my.
i've added the above code to the root folder, www.domain.com/
any suggestions? thanks?
*update
This my .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^.*$ http://www.domain.com%{REQUEST_URI} [R=301,L]
i'm getting an extra webroot/index.php?url= inserted into the url. Instead of www.domain.com/my/apple, i'm getting www.domain.com/my/webroot/index.php?url=apple
thanks to all once again.
Your code is not quite right. See below.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^.*$ http://www.domain.com%{REQUEST_URI} [R=301,L] # <-- Mind the 'L'!
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
if domain is .co.uk
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.co\.uk$ [NC]
RewriteRule ^.*$ http://www.domain.co.uk%{REQUEST_URI} [R=301,L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app/webroot/$1 [QSA,L]
I have tried the below code below and it worked for me:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^gigsadda\.com$ [NC]
RewriteRule ^.*$ http://www.gigsadda.com%{REQUEST_URI} [R=301,L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>