How can i rewrite URLs by myself?

Discussions and support about the different URL Rewriting techniques for phpBB.

Moderator: Moderators

How can i rewrite URLs by myself?

Postby tlgcmn » Mon Feb 08, 2010 3:50 pm

phpbb_seo mod handles URL rewriting of almost all necessary URLs but i want to rewrite some of the link URLs that is not rewritten by the mod and get rid of all "?" and "&" in my URLs.

For example, in subsilver2 based styles (like i use); when i view a topic page, there are "previous topic" and "next topic" links at the top right of the first message which helps to navigate between the topics in the current forum. If there is no previous or next topic, a message is displayed telling "There are no newer topics in this forum."

I don't know SEO, Google indexing and such things very well but isn't it cause duplicate pages?
For example; when i click previous from a topic, it opens this URL: localhost/phpbb/viewtopic.php?f=2&t=6&view=previous which is topic5. When i open topic5 in the forum by directly clicking, its URL is localhost/phpbb/ilk-forumunuz/topic5.html which is my preference to be indexed by search engines.

So there are two URLs, which will be indexed by Google and they have the same content. Also, Google will index some of my forum URLs that have "?" and "&" in it which i don't want.

Without redirection, how can i handle this problem? Also, i want to rewrite the URLs with "?". For example,
localhost/phpbb/viewtopic.php?f=2&t=6&view=previous should be sth. like localhost/phpbb/viewtopic/f2-t6/viewprevious.html

I have learned how to define RewriteRule in .htaccess. I think sth. like;
Code: Select all
RewriteRule ^phpbb/viewtopic-f(.*)-t(.*)-view(.*)\.html$ /phpbb/viewtopic.php?f=$1&t=$2&view=$3 [QSA,L,NC]
can handle what i need. But it isn't enough alone :( I need to rewrite the URL in the forum codes like you did which is the thing that i can't do.

Can you show me a way that how i can rewrite a URL with all necessary things? If you tell me on my example, it will be perfect but you can also give another example which can be reference for people like me that wants to make self URL rewritings.

I think preg_replace php function is used for rewriting, but still, i can't figure out totally how it works and above all, how can i use this rewritten URL and tell the phpbb to use it rather than the first one? :?
tlgcmn
 
Posts: 19
Joined: Wed Jan 27, 2010 3:07 pm

Advertisement

Re: How can i rewrite URLs by myself?

Postby dcz » Fri Mar 12, 2010 1:04 pm

The USU does not use regular expressions to parse the page in order to rewrite urls, it does the rewriting directly where links are builds (through append_sid()).

Then, the zero duplicate does take care of 100% of duplicates in strict mode and with the post redirection option set to at least "guests". This includes the view next/previous urls which are not rewritten because they are duplicate, even with the type of rewriting you suggest. Generating the ending url directly for these would require some extra SQL in viewtopic, so since they are handled by the zero dupe, there is no real need to do anything about them.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21325
Joined: Fri Apr 28, 2006 9:03 pm


Return to phpBB mod Rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 14 guests