.HTACCESS can it be run from a subfolder? How?
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
.HTACCESS can it be run from a subfolder? How?
[text]DirectoryIndex index.html index.htm index.php
order allow,deny
allow from all
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^([^/\.]+)/?$ index.php?page=$1&menu=home [L]
RewriteRule ^$ index.php?page=home&menu=home [L][/text]
Trying to run this from within : httpdocs/beta/
It won't work as it's looking in the ROOT.
So what do I need to add to make this work in /beta/, so I can test it for the client.
I cannot test it in a subdomain just yet.
order allow,deny
allow from all
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^([^/\.]+)/?$ index.php?page=$1&menu=home [L]
RewriteRule ^$ index.php?page=home&menu=home [L][/text]
Trying to run this from within : httpdocs/beta/
It won't work as it's looking in the ROOT.
So what do I need to add to make this work in /beta/, so I can test it for the client.
I cannot test it in a subdomain just yet.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: .HTACCESS can it be run from a subfolder? How?
You don't have to do anything special. Are you sure that .htaccess files are allowed and being interpreted?
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: .HTACCESS can it be run from a subfolder? How?
Yes. But surely that HTACCESS script is looking from the ROOT? There is no mention of the 'beta' folder and I wouldn't know how to put that in globally in HTACCESS.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: .HTACCESS can it be run from a subfolder? How?
It's not "looking" anywhere. If you put it in the beta/ subfolder then it will apply to the beta/ folder and everything underneath. That's how these files work.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: .HTACCESS can it be run from a subfolder? How?
But do you then have to change the hyperlinks to /beta/contact, or can that be done in HTACCESS? As I have links that are /contact.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: .HTACCESS can it be run from a subfolder? How?
You'd have to change the links, but your .htaccess can't do that for you. The only thing it can do is rewrite (for example) /contact to /beta/contact but it will either (a) not let you use /beta URLs or (b) break your POSTed forms.
Typical solution is to define a site root somewhere like
and use that everywhere you construct a URL.
Typical solution is to define a site root somewhere like
Code: Select all
define("SITE_ROOT", "/beta");-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: .HTACCESS can it be run from a subfolder? How?
I need to point a particular URL to show a full URL.
RewriteRule ^products/ /index.php?page=products&menu=home [L]
This is clearly wrong, but I need /products.... go to to index.php?page=home&menu=home.
How do I do the first bit??
Simon
RewriteRule ^products/ /index.php?page=products&menu=home [L]
This is clearly wrong, but I need /products.... go to to index.php?page=home&menu=home.
How do I do the first bit??
Simon
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: .HTACCESS can it be run from a subfolder? How?
Both of those try to rewrite from /products. Can't do that. The URLs have to be different.
Where is just "/products" supposed to go? For the other one, what URL is supposed to go to that?
Where is just "/products" supposed to go? For the other one, what URL is supposed to go to that?
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: .HTACCESS can it be run from a subfolder? How?
This is the list so far.
RewriteRule ^portfolio/([^/]+) /index.php?page=applications&menu=$1 [L]
RewriteRule ^portfolio/([^/]+)/([^/]+)/([0-9]+) /index.php?page=applications&menu=$1&application=$1&appid=$2 [L]
RewriteRule ^appprods/([^/]+)/([^/]+) /index.php?page=appprods&menu=$1&app=$2 [L]
RewriteRule ^appprods/([^/]+)/([^/]+)/([0-9]+)/([0-9]+)/([^/]+) /index.php?page=products&menu=$1&application=$2&appid=$3&product=$4&h=$5 [L]
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&catid=$1&category=$2&menu=categ [L]
RewriteRule ^categ/page/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=categ&c=$1&cname=$2&menu=categ&pagenum=$3 [L]
RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=product&catid=$1&category=$2&menu=categ&product=$3&h=$4 [L]
THIS is the one I am trying to sort out. Have tried just putting in any word after, that takes them to menu=categ.
RewriteRule ^products/([^/]+) /index.php?page=products&menu=categ [L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
RewriteRule ^$ index.php?page=home [L]
RewriteRule ^portfolio/([^/]+) /index.php?page=applications&menu=$1 [L]
RewriteRule ^portfolio/([^/]+)/([^/]+)/([0-9]+) /index.php?page=applications&menu=$1&application=$1&appid=$2 [L]
RewriteRule ^appprods/([^/]+)/([^/]+) /index.php?page=appprods&menu=$1&app=$2 [L]
RewriteRule ^appprods/([^/]+)/([^/]+)/([0-9]+)/([0-9]+)/([^/]+) /index.php?page=products&menu=$1&application=$2&appid=$3&product=$4&h=$5 [L]
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&catid=$1&category=$2&menu=categ [L]
RewriteRule ^categ/page/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=categ&c=$1&cname=$2&menu=categ&pagenum=$3 [L]
RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=product&catid=$1&category=$2&menu=categ&product=$3&h=$4 [L]
THIS is the one I am trying to sort out. Have tried just putting in any word after, that takes them to menu=categ.
RewriteRule ^products/([^/]+) /index.php?page=products&menu=categ [L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
RewriteRule ^$ index.php?page=home [L]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: .HTACCESS can it be run from a subfolder? How?
Code: Select all
RewriteRule ^solutions/([^/]+) /index.php?page=solutions&menu=$1 [L]
RewriteRule ^solutions/sol/([^/]+) /index.php?page=$1&menu=sol [L]The top one works. ..../solutions/sol, will take the user to index.php?page=solutions&menu=sol.
But ..../solutions/sol/sol_yachts just takes them back to the solutions/sol above.
Why is that?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.