So I am trying to teach myself and it's going pritty well. besides the fact that I want to rewrite my url:
http://www.jeplabyggochtradgard.com/webroot/Index.php
Where webroot is a fixed folder but after that there may be more folders/files...
I'm not a wizard when it comes to regex (I try I really do) but I do my best.
Now I asked my host and they have rewrite on so I can do this if I do it correctly...
I added .htaccess file to the root of my domain.
Now I'm asking for help to figure out what I need todo with the rewriteRule, base and all those :/
I've been looking over pages such as:
https://24ways.org/2013/url-rewriting-for-the-fearful/
http://stackoverflow.com/questions/1047 ... -from-urls
Amongst a few...
But I still don't get the syntaxing of it and what the diffrent, "RewriteRule:, RewriteBase: ..." does.
Thanks in Advance,
Thomas
URL Rewrite
Moderator: General Moderators
Re: URL Rewrite
First, when you say you put a .htaccess in the root of the domain, you mean /.htaccess and not /webroot/.htaccess, right?
Second, what are you trying to rewrite to what?
I generally don't use RewriteBase. Most circumstances where you might want it just aren't that important. Here you'd probably use "RewriteBase webroot/", but instead of that you could just put the .htaccess at /webroot/.htaccess instead and not have to bother with it.
Quick primer:
1. RewriteRule takes the current URL path - not query string - as the string to run the regex against, then the regex to test for. It can capture stuff and most of the time you'll need that. It does a sort of search/replace on the path and turns it into another path. After that there are some flags which can affect what happens.
2. Then there's RewriteCond. It only acts as a condition, not doing any work short of determining whether something is true or not. You can use it to check the query string (which isn't available in a RewriteRule) or to run multiple conditions on the path itself or do many other sorts of things. Each one only applies to the next RewriteRule.
3. You can do very complicated things with URL rewriting.
Second, what are you trying to rewrite to what?
I generally don't use RewriteBase. Most circumstances where you might want it just aren't that important. Here you'd probably use "RewriteBase webroot/", but instead of that you could just put the .htaccess at /webroot/.htaccess instead and not have to bother with it.
Quick primer:
1. RewriteRule takes the current URL path - not query string - as the string to run the regex against, then the regex to test for. It can capture stuff and most of the time you'll need that. It does a sort of search/replace on the path and turns it into another path. After that there are some flags which can affect what happens.
2. Then there's RewriteCond. It only acts as a condition, not doing any work short of determining whether something is true or not. You can use it to check the query string (which isn't available in a RewriteRule) or to run multiple conditions on the path itself or do many other sorts of things. Each one only applies to the next RewriteRule.
3. You can do very complicated things with URL rewriting.
Re: URL Rewrite
Alright so yes it's the base root so it's /.htaccess Didn't even think you could place it within a diffrent folder such as webroot.
Now for what I am trying to accomplish:
I want it to at any time and all the time be the main domain only and no filenames or even folder displayed in the URL.
So anything like this:
www.jeplabyggochtradgard.com/webroot/Index.php
Would be:
www.jeplabyggochtradgard.com
Thank you for the primer but what I really don't get is the syntax it's using where to place what and how to use it..
is the RewriteCond more or less like a IF statement that will run the RewriteRule if it is true?
How do I write the RewriteRule... You mentioned something about it being like a search and replace I like that but how do I use it.
RewriteRule "", "", ""
Something like this ^
And what and how do I write it to become a correct rule?
Thanks in Advance,
Thomas
Now for what I am trying to accomplish:
I want it to at any time and all the time be the main domain only and no filenames or even folder displayed in the URL.
So anything like this:
www.jeplabyggochtradgard.com/webroot/Index.php
Would be:
www.jeplabyggochtradgard.com
Thank you for the primer but what I really don't get is the syntax it's using where to place what and how to use it..
is the RewriteCond more or less like a IF statement that will run the RewriteRule if it is true?
How do I write the RewriteRule... You mentioned something about it being like a search and replace I like that but how do I use it.
RewriteRule "", "", ""
Something like this ^
And what and how do I write it to become a correct rule?
Thanks in Advance,
Thomas