This is a discussion on htaccess redirect within the Apache Web Server forums, part of the Web Server and Related Forums category; Hi Folks, What is wrong with this redirect? RewriteEngine on RewriteRule ^([0-9a-zA-Z\-\_]+)\.html$index.php?page=$...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi Folks,
What is wrong with this redirect? RewriteEngine on RewriteRule ^([0-9a-zA-Z\-\_]+)\.html$index.php?page=$1 filename.html ----> index.php?page=filename [ works fine ] file-name.html ---> [errors] I have escaped the - but for some reason it still doesnt work? Also, if I put this in the public_html root - will that affect all subfolders (which in my config include other websites)? Is there something I can limit it to say only this folder? Many thanks A |
|
|||
|
UKuser escribió:
> RewriteEngine on > RewriteRule ^([0-9a-zA-Z\-\_]+)\.html$index.php?page=$1 If I insert a white space between $ and index it works fine for me. > > filename.html ----> index.php?page=filename [ works fine ] > file-name.html ---> [errors] Read the errors. The often give a clue ;-) > Also, if I put this in the public_html root - will that affect all > subfolders (which in my config include other websites)? Yes. However, since paths with slashes don't match your regexp it should not be a great deal. -- -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain -- Mi sitio sobre programación web: http://bits.demogracia.com -- Mi web de humor al baño María: http://www.demogracia.com -- |
|
|||
|
On Jun 24, 9:41*am, "Álvaro G. Vicario"
<alvaroNOSPAMTHA...@demogracia.com> wrote: > UKuser escribió: > > > RewriteEngine on > > RewriteRule ^([0-9a-zA-Z\-\_]+)\.html$index.php?page=$1 > > If I insert a white space between $ and index it works fine for me. > > > > > filename.html ----> index.php?page=filename *[ works fine ] > > file-name.html ---> [errors] > > Read the errors. The often give a clue ;-) > > > Also, if I put this in the public_html root - will that affect all > > subfolders (which in my config include other websites)? > > Yes. However, since paths with slashes don't match your regexp it should > not be a great deal. > > -- > --http://alvaro.es- Álvaro G. Vicario - Burgos, Spain > -- Mi sitio sobre programación web:http://bits.demogracia.com > -- Mi web de humor al baño María:http://www.demogracia.com > -- Hi Alvaro - I've put it on a new line and tidied it up and its still not working? |
|
|||
|
UKuser escribió:
>>> RewriteEngine on >>> RewriteRule ^([0-9a-zA-Z\-\_]+)\.html$index.php?page=$1 >> If I insert a white space between $ and index it works fine for me. > Hi Alvaro - I've put it on a new line and tidied it up and its still > not working? You can't split directives in several lines. Try what I said: RewriteEngine on RewriteRule ^([0-9a-zA-Z\-\_]+)\.html$ index.php?page=$1 And let me insist: if you get error messages, *read* them! And if you don't understand them, you could even post them here. -- -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain -- Mi sitio sobre programación web: http://bits.demogracia.com -- Mi web de humor al baño María: http://www.demogracia.com -- |