Rewrite

Discussion forum for MOD Writers regarding MOD Development.
ultimateguy
Registered User
Posts: 48
Joined: Tue Mar 26, 2013 11:53 pm

Rewrite

Post by ultimateguy »

Hi,

I have got this codes

Code: Select all

RewriteEngine On
RewriteBase /
RewriteRule ^s/(.*).pl$ /cgi-bin/$1.php [L]
RewriteRule ^htaccess/.+/([^/]+.html)$ /htaccess/index.php [R=301,L]
RewriteRule ^htaccess/.+-vc([0-9]+).html$ /htaccess/index.php?c=$1 [QSA,L]
RewriteRule ^htaccess/.+-vf([0-9]+)-([0-9]+).html$ /htaccess/viewforum.php?f=$1&start=$2 [QSA,L]
RewriteRule ^htaccess/.+-vf([0-9]+).html$ /htaccess/viewforum.php?f=$1 [QSA,L]
RewriteRule ^htaccess/.+-vt([0-9]+)-([0-9]+).html$ /htaccess/viewtopic.php?t=$1&start=$2 [QSA,L]
RewriteRule ^htaccess/.+-vt([0-9]+).html$ /htaccess/viewtopic.php?t=$1 [QSA,L]
RewriteRule ^htaccess/post([0-9]+).html$ /htaccess/viewtopic.php?p=$1 [QSA,L]
RewriteRule ^htaccess/member([0-9]+).html$ /htaccess/profile.php?mode=viewprofile&u=$1 [QSA,L]
and I have placed them in .htaccess But I don't any difference :( I have the mod rewrite thing module installed on the server :?

EDIT:
From http://www.askapache.com/htaccess/last- ... phpbb.html
User avatar
Lumpy Burgertushie
Registered User
Posts: 69223
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Rewrite

Post by Lumpy Burgertushie »

this has to do with mod-rewrite and probably phpbb-seo which is not the same files that you get from here.

also none of that is needed for good SEO with phpbb. the search engines find all of the phpbb pages just fine without changing the URLs/filenames at all.


robert
Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53400
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Rewrite

Post by Brf »

What "difference" are you expecting?
What URLs are you typing into your webbrower to be rewritten?
User avatar
Lumpy Burgertushie
Registered User
Posts: 69223
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Rewrite

Post by Lumpy Burgertushie »

I just noticed that you have all of those files listed in a folder named htaccess. there is no folder named htaccess and there shouldn't be.


robert
Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
5hocK
Registered User
Posts: 3139
Joined: Wed Nov 23, 2011 7:00 pm
Location: UK

Re: Rewrite

Post by 5hocK »

ultimateguy wrote:I have got this codes................. http://www.askapache.com/htaccess/last- ... phpbb.html
That guide is from Nov 07, 2006, probably best to forget you ever found it. Also a good tip to try and solve one thing at a time ;)
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53400
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Rewrite

Post by Brf »

I am betting the he is thinking the htaccess is going to change all of the URLs in his phpBB.
That is not what mod_rewrite does. What it does is take the URL typed in your webbrowser's addressbar and direct it to a different page. For instance, that code will direct a /htaccess/member1234.html to the address /htaccess/profile.php?mode=viewprofile&u=1234
Of course profile.php does not exist in phpBB3
User avatar
Lumpy Burgertushie
Registered User
Posts: 69223
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Rewrite

Post by Lumpy Burgertushie »

and there is no folder named htaccess in phpbb and there shouldn't be one on your server.

htaccess is a file ( not a folder ) where you would put that mod rewrite stuff once you learn how to use it and what it is for.


robert
Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
ultimateguy
Registered User
Posts: 48
Joined: Tue Mar 26, 2013 11:53 pm

Re: Rewrite

Post by ultimateguy »

Just want to make it work for phpBB 3 :lol:
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53400
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Rewrite

Post by Brf »

As we already explained, it will not "work" unless you plan on typing those incorrect URLs into yor webbrowser.

The member1234.html part...
ultimateguy
Registered User
Posts: 48
Joined: Tue Mar 26, 2013 11:53 pm

Re: Rewrite

Post by ultimateguy »

I changed to this code but still no difference :(

Code: Select all

RewriteEngine On
RewriteBase /
RewriteRule ^s/(.*).pl$ /cgi-bin/$1.php [L]
RewriteRule ^.+/([^/]+.html)$ /index.php [R=301,L]
RewriteRule ^.+-vc([0-9]+).html$ /index.php?c=$1 [QSA,L]
RewriteRule ^.+-vf([0-9]+)-([0-9]+).html$ /viewforum.php?f=$1&start=$2 [QSA,L]
RewriteRule ^.+-vf([0-9]+).html$ /viewforum.php?f=$1 [QSA,L]
RewriteRule ^.+-vt([0-9]+)-([0-9]+).html$ /viewtopic.php?t=$1&start=$2 [QSA,L]
RewriteRule ^.+-vt([0-9]+).html$ /viewtopic.php?t=$1 [QSA,L]
RewriteRule ^post([0-9]+).html$ /viewtopic.php?p=$1 [QSA,L]
RewriteRule ^member([0-9]+).html$ /memberlist.php?mode=viewprofile&u$1 [QSA,L]
I have my forum in sub folder like 127.0.0.1:8080/forum
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53400
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Rewrite

Post by Brf »

Did you type member1234.html into your webbrower's addressbar?
pbrouwers
Registered User
Posts: 58
Joined: Wed Nov 11, 2009 11:07 am

Re: Rewrite

Post by pbrouwers »

Remove the RewriteBase /
And the slash before /index.php, /memberlist.php, ..

In your rewrite url for the member you have a little mistake.

Code: Select all

RewriteRule ^member([0-9]+).html$ memberlist.php?mode=viewprofile&u=$1 [QSA,L]
You forgot the = between u and $1.

member2.html will work now. (With those changes it does for me)

I don't know exactly how you want to display the others? topicname-vt10.html ?

Edit: welcome-to-phpbb3-vt1.html & your-first-forum-vf2.html work.
ultimateguy
Registered User
Posts: 48
Joined: Tue Mar 26, 2013 11:53 pm

Re: Rewrite

Post by ultimateguy »

Thanks :) Can you please change the complete to working code and share it here? Please thank You :)

Yes, Just like that :D
pbrouwers
Registered User
Posts: 58
Joined: Wed Nov 11, 2009 11:07 am

Re: Rewrite

Post by pbrouwers »

Rewrite:

Code: Select all

RewriteEngine On
RewriteRule ^.+-vc([0-9]+).html$ index.php?c=$1 [QSA,L]
RewriteRule ^.+-vf([0-9]+)-([0-9]+).html$ viewforum.php?f=$1&start=$2 [QSA,L]
RewriteRule ^.+-vf([0-9]+).html$ viewforum.php?f=$1 [QSA,L]
RewriteRule ^.+-vt([0-9]+)-([0-9]+).html$ viewtopic.php?t=$1&start=$2 [QSA,L]
RewriteRule ^.+-vt([0-9]+).html$ viewtopic.php?t=$1 [QSA,L]
RewriteRule ^post([0-9]+).html$ viewtopic.php?p=$1 [QSA,L]
RewriteRule ^member([0-9]+).html$ memberlist.php?mode=viewprofile&u=$1 [QSA,L]
Use:

Code: Select all

your-first-category-vc1.html
your-first-forum-vf2-2.html
your-first-forum-vf2.html
welcome-to-phpbb3-vt1-2.html
welcome-to-phpbb3-vt1.html
post1.html
member2.html
Note: these rewrite rules will only work when you enter them in the browser. (127.0.0.1:8080/forum/member2.html)

When you click on a topic link, it will just display the normal viewtopic.php
ultimateguy
Registered User
Posts: 48
Joined: Tue Mar 26, 2013 11:53 pm

Re: Rewrite

Post by ultimateguy »

:o Anyway to use rewritten urls?
Locked

Return to “[3.0.x] MOD Writers Discussion”