| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Spare Parts
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,532
|
.htaccess navigation
I am trying to set up navigation by directory address similar to Wordpress. So mydomain.com/hello goes to mydomain.com/index.php?var=hello I have got this far but not quite right, any clues? Thanks. Options +FollowSymlinks RewriteEngine On RewriteRule ^/ index.php?var=$1 ![]() |
|
|
|
|
|
#2 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,874
|
Code:
If you've a range of sections/pages, you can match is against a pattern. e.g. Code:
…or… Code:
|
|
|
|
#3 (permalink) |
|
Spare Parts
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,532
|
Thanks Bill, unfortunately it won't work. The first one index.php is not reacting to the variable and the second crashes the server for all files. Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. |
|
|
|
#4 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,874
|
The second one contains an error. (Oops!) The hyphen near the end should be the first character… Code:
The use of the var name var may also be causing issues, as it may be a protected keyword. It's worth using another name for the parameter, just to be safe. On the index.php, you'd access the parameters using $_GET['paramName'] (paramName being whatever name you use for the parameter. |
|
|
|
#6 (permalink) | |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,874
|
Quote:
This one…? Code:
…or this one…? Code:
In both cases, the rule will only work for exact matches. The hello one will only forward a request from yourdomain.com/hello or yourdomain.com/hello/ to yourdomain.com/index.php?var=hello The second one will only forward the following url requests Code:
|
|
|
|
|
#7 (permalink) |
|
i'm done, son
Join Date: Jan 2005
Posts: 12,262
|
I like the way Drupal handles things. Code:
Code:
Code:
|
|
|
|
#8 (permalink) |
|
Spare Parts
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,532
|
It was this one Bill RewriteRule ^([page1|page2|page3|page4])/?$ index.php?var=$1 When I change page1 for hello it should function but does not. But no never mind I am entirely content with the other. Thanks. |
|
![]() |