PDA

View Full Version : Rewrite problem


Kurogane
03-28-2009, 05:32 PM
I have a problem with the rewrite i have this rules.

RewriteRule ^example$ /example.html

is seems the rules is ok

When i try to go www.example.net/example i got 404 error, i search in the logs i see this

[REWRITE] Rule: Match '/example' with pattern '^example$', result: -1
2009-03-28 18:11:43.479 [INFO] [x.x.x.x:2318-0#example] File not found [/home/user/example.net/example]

RewriteRule ^example(.*) example.html

[REWRITE] Rule: Match '/example' with pattern '^example(.*)', result: -1
2009-03-28 18:22:37.221 [INFO] [x.x.x.x:2912-1#example] File not found [/home/user/example.net/example]

In whatever rules always try to find this path /home/user/example.net/example of course there are not folder name example and that is why i have 404 error.

So my question is how i can fix this problem there are something wrong on my rules.

Thanks

mistwang
03-29-2009, 12:53 PM
That rewrite rule is for .htaccess, to use it at vhost level you need to add leading '/'.

RewriteRule ^/example$ /example.html

Kurogane
03-29-2009, 06:23 PM
For some reason rewrite you give me works i really sure i test that maybe cache problem anyways.

I have two question more

1. Is possible to catch all html file and convert to in www.example.net/something, for example i try this

RewriteRule ^(/.+)$ /$1.html

Is work i want, but unfortunately not all, it's convert all file in end .html in images/1.gif.html images/2.gif.html etc

2. How i can do redirect a url? i try this.

RewriteRule ^/redirect$ http://www.otherurl.com
RewriteRule ^/redirect$ /http://www.otherurl.com

and neither work for me.

Thanks for you help

mistwang
03-30-2009, 11:17 AM
1. you need to use a regular expression only match to what you want and filter the others. like, exclude all string with "." in it.
^/([^\.]+)$

2. it should work, maybe you need to append a slash to the target URL.