koolaid
08-31-2007, 09:14 PM
Hello,
I don't know much about htaccess, but i'm trying to redirect all stuff coming from index.php to the root, so e.g. /index.php?test=1 becomes /1, now that WOKRS. But now here's my problem, i cannot make any new php files because if i would go to /anotherfile.php it would redirect to the root again...
Here's the code:
RewriteEngine On
RewriteRule (.*) index.php
Can anyone help so i can add new php files that won't be redirected?
Try the following
RewriteEngine on
RewriteBase /
RewriteRule ^(.+)/?$ /index.php?page=$1 [L]
now, when you create links in your html, make sure it starts with "/"...for example
<a href="/about/">about</a>
<a href="/contact/">contact</a>
Let's know if that didn't work
cheers,
Ess
koolaid
09-01-2007, 05:18 PM
Try the following
RewriteEngine on
RewriteBase /
RewriteRule ^(.+)/?$ /index.php?page=$1 [L]
now, when you create links in your html, make sure it starts with "/"...for example
<a href="/about/">about</a>
<a href="/contact/">contact</a>
Let's know if that didn't work
cheers,
Ess
Well i tried it, but it gives me a 404...
is mod_rewrite enabled?
you wish to have a look at the following url, they seem to provide a interesting solution
http://framework.zend.com/wiki/display/ZFDEV/Configuring+Your+URL+Rewriter
cheers,
Ess
koolaid
09-02-2007, 11:56 AM
is mod_rewrite enabled?
you wish to have a look at the following url, they seem to provide a interesting solution
http://framework.zend.com/wiki/display/ZFDEV/Configuring+Your+URL+Rewriter
cheers,
Ess
Messed around a bit, and it works! Thanks a million! Small question though, what does the '^' in front of '(.+)' mean?
^ means match the beginning of a given value
for example
^([a-z]+)(\s)([0-9]+)$
the above expression states the string must start with at the least one letter, which could be a, b, c....all the way to z
$ means the ends of a string
in the above example, a value would evaluate to true if it ends with at the least one number 0-9
for more info, please check the following url
http://www.regular-expressions.info/
cheers,
Ess