Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite trailing slash problem

         

whoomp

10:10 pm on Dec 28, 2004 (gmt 0)

10+ Year Member



Hello,

I'm new to this whole mod_rewrite thing.
I'm trying to create a system that allows multiple forums, but it isn't working out as planned.

I have a problem with the trailing slash resulting in a 404 error.

e.g. : [example.be...]
but [example.be...] works fine

the code i use is :


Options Indexes FollowSymLinks MultiViews All
RewriteEngine On
RewriteRule ^forums/(.*)/phpbb(.*) /forums/phpbb/$2

Any help would be nice :)

[edited by: jdMorgan at 5:26 pm (utc) on Dec. 29, 2004]
[edit reason] Removed specifics per TOS. [/edit]

jdMorgan

10:36 pm on Dec 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



whoomp,

Welcome to WebmasterWorld!

Your Options settings are inconsistent... I'd suggest you look up each Option [httpd.apache.org] and make sure you need it. If you don't need MultiViews for content negotiation, turn it off, as it can cause this problem. Otherwise, "Options All" covers the rest of them.

I can't suggest changes to the code because I don't understand all the details of your site layout. You might want to explain the code you have (in detail) and what you hope to accomplish with it. For example, what is the "1" between "/forums/" and "/phpbb"? Is it always present? What values might it have other than "1"? Why do you test for it, and why do you discard it if present? If you want a precise answer, then these questions need to be addressed.

Jim

whoomp

11:16 am on Dec 29, 2004 (gmt 0)

10+ Year Member



Right,

the real url of the forum is : [example.be...]

That 1 is meant to change, I'm trying to setup a free forum hosting service.
Basicly i just want that it rewrites it to the normal forum. And with php i can read the number (in this case 1).

Hope this is enough.

[edited by: jdMorgan at 5:23 pm (utc) on Dec. 29, 2004]
[edit reason] Removed specifics per TOS [/edit]

whoomp

11:22 am on Dec 29, 2004 (gmt 0)

10+ Year Member



Also, deleting the Options line doesn't change anything

whoomp

12:51 pm on Dec 29, 2004 (gmt 0)

10+ Year Member



for some reason i can't edit my posts :
Now when i change
RewriteRule ^forums/(.*)/phpbb/(.*) /forums/phpbb/$2

to
RewriteRule ^forums/(.*)/phpbb/?(.*) /forums/phpbb/$2

[example.be...] loads but the images aren't displaying

[edited by: jdMorgan at 5:24 pm (utc) on Dec. 29, 2004]
[edit reason] Removed specifics per TOS. [/edit]

jdMorgan

5:33 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need to exclude images from being rewritten:

RewriteCond %{REQUEST_URI} !\.(gif¦jpe?g¦png)$
RewriteRule ^forums/(.+/)?phpbb/?(.*) /forums/phpbb/$2 [L]

The RewriteCond prevents .gif, .jpeg, .jpg, and .png file requests from being rewritten.

Note that the broken pipe "¦" characters above will need to be replaced with solid pipes from your keyboard before use. Posting on this board modifies those characters.

Jim

whoomp

5:37 pm on Dec 29, 2004 (gmt 0)

10+ Year Member



I chenged the pipes, but i'm getting an internal server error.

RewriteCond %{REQUEST_URI}!\.(gif¦jpe?g¦png)$
RewriteRule ^forums/(.+/)?phpbb/?(.*) /forums/phpbb/$2 [L]