1

Topic: .htaccess redirect .php to non

Im trying to redirect older page that have .php extensions to wolf cms pages that I would not like to have the .php anymore.

I have already remove the suffix in the config.php file

// Add a suffix to pages (simluating static pages '.html')
define('URL_SUFFIX', '');

I tried this :

 RewriteRule ^(.*)\.php$ /$1 [R=301,L] 

but keep getting this :

/index?WOLFPAGE=page.php

The goal is to is to redirect all pages that have the .php extension to non php so that I dont lose search engine rank.

Example:
redirect this page1.php => to this page1
redirect this page2.php => to this page2

what am I missing here ?

Last edited by don (2012-03-13 21:04)

Thumbs up

2

Re: .htaccess redirect .php to non

Post the entire set of htaccess file content... the order or the rewrite rules is important

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution or see our financial report first.

3

Re: .htaccess redirect .php to non

AddDefaultCharset UTF-8
Options -Indexes +FollowSymLinks

<IfModule mod_rewrite.c>
  RewriteEngine On
  # Set next line to your Wolf CMS root - if not in subdir, then just /
  RewriteBase /

  # Rules to allow install sequence to test for mod_rewrite support
  RewriteRule ^wolf/install/index.html$ wolf/install/index.php?rewrite=1 [L,QSA]
  RewriteRule ^wolf/install/index.php$ wolf/install/index.php?rewrite=1 [L,QSA]
  RewriteRule ^wolf/install/$ wolf/install/index.php?rewrite=1 [L,QSA]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l

  # Main URL rewriting.
  RewriteRule ^(.*)$ index.php?WOLFPAGE=$1 [L,QSA]

</IfModule>

AddType x-mapp-php .php4
AddType x-mapp-php5 .php
AddHandler x-mapp-php .php4
AddHandler x-mapp-php5 .php

this is my entire set of htaccess file content

Thumbs up

4

Re: .htaccess redirect .php to non

Okay... two remarks...

1. I don't see the rewrite rule you added in your htaccess file...

2. The rewrite rule you had was also rewriting Wolf CMS's index.php so you will have to make sure you don't do that.

Something like this: (added BEFORE the main Wolf CMS rewrite)

RewriteCond $1 !^(index\.php)$
RewriteRule ^(.*)\.php$ /$1 [R=301,L]
Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution or see our financial report first.

5

Re: .htaccess redirect .php to non

Try this:

<IfModule mod_rewrite.c>
  RewriteEngine On
  # Set next line to your Wolf CMS root - if not in subdir, then just /
  RewriteBase /
  
  RewriteRule ^(.+)\.php$ $1 [R,NC]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  
  # Main URL rewriting.
  RewriteRule ^(.*)$ index.php?WOLFPAGE=$1 [L,QSA]

</IfModule>

Last edited by Fortron (2012-03-13 22:56)

6

Re: .htaccess redirect .php to non

The rewritecond would probably be safer... smile

(except I made a little typo in it... now corrected)

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution or see our financial report first.

7

Re: .htaccess redirect .php to non

Hi all,

I may not be on the right track here but thought I would post anyway...

If your are trying to catch and redirect pages from an old site to your new wolf site, there is an awesome redirector plugin by realslacker - see here:

http://www.wolfcms.org/repository/29

Thanks,
Chris

8

Re: .htaccess redirect .php to non

emcon227 wrote:

If your are trying to catch and redirect pages from an old site to your new wolf site, there is an awesome redirector plugin by realslacker - see here:

http://www.wolfcms.org/repository/29

Forgot about that! smile

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution or see our financial report first.

9

Re: .htaccess redirect .php to non

emcon227 wrote:

Hi all,

I may not be on the right track here but thought I would post anyway...

If your are trying to catch and redirect pages from an old site to your new wolf site, there is an awesome redirector plugin by realslacker - see here:

http://www.wolfcms.org/repository/29

Thanks,
Chris

This actually worked but the only thing is that you have to do it manually one by one. wonder if I can import them through phpmyadmin

Last edited by don (2012-03-14 18:45)

Thumbs up

10

Re: .htaccess redirect .php to non

mvdkleijn wrote:

Okay... two remarks...

1. I don't see the rewrite rule you added in your htaccess file...

2. The rewrite rule you had was also rewriting Wolf CMS's index.php so you will have to make sure you don't do that.

Something like this: (added BEFORE the main Wolf CMS rewrite)

RewriteCond $1 !^(index\.php)$
RewriteRule ^(.*)\.php$ /$1 [R=301,L]

This actually worked great but it also changed my CSS and .JS file paths for both admin/frontend so I will try to figure that out.

Last edited by don (2012-03-14 15:07)

Thumbs up

11

Re: .htaccess redirect .php to non

Just add the ones you don't want... like for example:

RewriteCond $1 !^(index\.php|.*\.js|.*\.gif|.*\.png|.*\.jpg|.*\.css)$
RewriteRule ^(.*)\.php$ /$1 [R=301,L]

Or you can just add an entire path to ignore for this rule. (like everything in the public directory for example) I'll leave that as an exercise though. :-p

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution or see our financial report first.