Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Possible to rewrite old url's ?

Hi,

After converting from phpbb to vanilla the links users posted on phpbb to other topics no longer work because the url has changed. Is it possible to fix this with a rewrite rule ? (I'm on Apache). URL's look like this:

OLD: http://www.audi-a2.nl/cc-hendel-plaatsen-voor-een-1-2tdi-3l-t3174.html
NEW: http://www.audi-a2.nl/discussion/3174/cc-hendel-plaatsen-voor-een-1-2tdi-3l

Thanks for your input !

Comments

  • Options
    x00x00 MVP
    edited October 2014
    RewriteRule ^(.*?)-t([0-9]+)\.html$ discussion/$2/$1 [L]
    

    grep is your friend.

  • Options

    You may want to use [R=301] instead of [L]

    grep is your friend.

  • Options

    Thanks @x00 that was beyond my grep knowledge. Both links now lead to the correct page. Thanks.

  • Options

    Why is that @x00 ? When I make that change I get a "page not found"

  • Options

    It's probably clashing with other rewrite rules. Try both: [R=301,L]

  • Options
    piotrnlpiotrnl New
    edited October 2014

    This is my .htaccess. I'm not to familiar with Apache. When I add the suggested R=301 I get a page not found.

    `# Modified

    RewriteEngine On

    # Certain hosts may require the following line.

    # If vanilla is in a subfolder then you need to specify it after the /.

    # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)

    # RewriteBase /

    RewriteRule ^(.*?)-t([0-9]+).html$ discussion/$2/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]

    `

  • Options
    RewriteRule ^(.*?)-t([0-9]+).html$ %{REQUEST_SCHEME}://%{HTTP_HOST}/discussion/$2/$1 [L, R=301]
    

    grep is your friend.

  • Options
    peregrineperegrine MVP
    edited October 2014

    also, you may have another issue. What folder is your forum in? by removing the # on RewriteBase line

    if so read this

    # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
    
    # RewriteBase /
    

    and change accordingly. e.g.

    if in root folder

    RewriteBase /

    if in vanilla

    RewriteBase /vanilla

    if forum is located in /Sometherfolder

    RewriteBase /Sometherfolder

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    My forum is root @peregrine hence the # ;-)

Sign In or Register to comment.