Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite problem

         

dobberph

4:11 pm on Aug 25, 2010 (gmt 0)

10+ Year Member



Hi all,

I just want to make a rule like that:
Normally my links are:
index.php?view=Home&action=edit&id=23

This I want to transform to

Home/edit/23

I started with:

RewriteRule ^([^\.]+)$ index.php?view=$1


This works.

No I have the problem that also a trailing slash shall be accepted. As Home/

Therefore I tried:

RewriteRule ^([^/.]+)/?$ index.php?view=$1


If I try this afterwards apache does something, but not the correct. It loads the page but without css and some other things missing.

What is wrong with this?

Best regards,
DerTobi

jdMorgan

6:07 pm on Aug 25, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem is that you have used page-relative links to include css, images, and external Javascripts. Since your new URL now ends with a slash, your browser is requesting those objects from the /Home subdirectory, as in "example.com/Home/logo.gif".

To fix this problem use canonical URLs or use server-relative linking in your pages, not page-relative linking.

That is, do not link as <img src="logo.gif">. Use <img src="http://www.example.com/logo.gif"> or <img src="/logo.gif"> instead.

Also you *should not* allow both kinds of URLs to resolve to the same "page" or you will be creating a duplicate-content problem for yourself. Instead, pick either trailing-slash page URLs or non-trailing-slash page URLs, and externally redirect the "wrong ones" to the "right ones." This prevents duplicate content problems with your search rankings, and should you decide to use the no-trailing-slash page URLs, your problem with page-relative-linked objects goes away as well...

Jim

dobberph

1:07 pm on Aug 26, 2010 (gmt 0)

10+ Year Member



Ah ok.

For my next project I will to this from the beginning.
It's too much now.

I use now a komma to separate.

Thank you.