htaccess redirect

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=$...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-24-2008
UKuser
 
Posts: n/a
Default htaccess redirect

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
  #2 (permalink)  
Old 06-24-2008
Álvaro G. Vicario
 
Posts: n/a
Default Re: htaccess redirect

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
--
  #3 (permalink)  
Old 06-24-2008
UKuser
 
Posts: n/a
Default Re: htaccess redirect

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?
  #4 (permalink)  
Old 06-24-2008
Álvaro G. Vicario
 
Posts: n/a
Default Re: htaccess redirect

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
--
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:04 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0