1 of 2
1
Rewrite Module (Redirect URL’s to new ones) 301/302/Script/Meta
Posted: 28 May 2008 11:25 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  716
Joined  07-02-2007

Rewrite Module + Extension

There are no EE tags, it’s all inside the module configuration page.

Redirect Methods:
-Normal
-301 (Moved Permanently)
-302 (Moved Temporarily)
-Javascript + Optional: Timeout/Page_title/Body Message
-META Refresh + Optional: Timeout/Page_title/Body Message
-Start Date & End Date
-Enable/Disable
-“Directory” Redirection.

Updated to 2.0:

-Fixes some bugs
-Added directory redirection
-Auto enable/disable extension when module get installed/removed
-and some jquery magic in the module CP .

Feature requests welcome, bugs too !

And yes, 301/302 redirect headers are sent before normal page_headers

Image Attachments
rewrite_2.0.jpg
Click thumbnail to see full-size image
File Attachments
rewrite_2.0.zip  (File Size: 111KB - Downloads: 97)
 Signature 

Truly ExpressionEngine


Fielder Module ( Mass Custom Fields )
Super Cache (Cache heavy tag output)
reCAPTCHA Extension
Rewrite Module


See all my EE Addons (8)

Profile
 
 
Posted: 28 May 2008 11:55 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  135
Joined  05-25-2002

Victor, great idea and thaks! I’m excited about test module. It seems, there is missing extension file in the package.

 Signature 

Caleydon Media

+ CM Strange URL Interpreter
+ CM Textarea Resizer
+ CM Template Editor (EditArea)

Profile
 
 
Posted: 28 May 2008 12:14 PM   [ Ignore ]   [ # 2 ]  
Moderator
Avatar
RankRankRankRank
Total Posts:  1994
Joined  05-07-2007

Victor,

Very nice!  Can we use it to redirect when a site is re-built?  eg:  http://example.com/mypage.html to http://example.com/index.php/my_page

-greg

 Signature 
Profile
MSG
 
 
Posted: 28 May 2008 12:34 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  716
Joined  07-02-2007
Gabriel - 28 May 2008 11:55 AM

Victor, great idea and thaks! I’m excited about test module. It seems, there is missing extension file in the package.

Hi Gabriel,
I added the extension file, re-download the .zip package

Victor,

Very nice!  Can we use it to redirect when a site is re-built?  eg:  http://example.com/mypage.html to http://example.com/index.php/my_page

Well you can redirect: http://example.com/mypage.html
to: http://example.com/index.php/my_page

But you can’t redirect directories with subpages to another directory yet
Example:

Works:
URL: http://www.example.com/something/now/
TO: http://www.example.com/another/

Doesn’t Work:
URL: http://www.example.com/something/now/
MATCH: http://www.example.com/something/now/subpage/
MATCH: http://www.example.com/something/now/subpage2/
TO: http://www.example.com/another/

Only the URL will be redirected.. Since sub-pages don’t match the original URL.
I will add that feature in the next version, already thinking for a easy solution.

 Signature 

Truly ExpressionEngine


Fielder Module ( Mass Custom Fields )
Super Cache (Cache heavy tag output)
reCAPTCHA Extension
Rewrite Module


See all my EE Addons (8)

Profile
 
 
Posted: 28 May 2008 12:56 PM   [ Ignore ]   [ # 4 ]  
Moderator
Avatar
RankRankRankRank
Total Posts:  1994
Joined  05-07-2007

Victor.

I will put this to use now, as I have a site to try to roll out this week!  =)

-greg

 Signature 
Profile
MSG
 
 
Posted: 29 May 2008 02:26 AM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6543
Joined  04-15-2006

Hi Victor,

Looks like a fantastic module you have created there. Is there any stopping you? wink

Well you asked for Feature Requests so here goes grin

Not really understanding re-directs myself so this may or may not be possible but it struck me as a possibility that maybe this module could work with wild-card matching?

Say someone has many many URLS all like this :

http://www.example.com/media/june/2007/detail/name_of_post

Could you make a wildcard entry so that you could do this kind of thing :

Old URLs
http://www.example.com/media/june/2007/detail/*

New URLs
http://www.example.com/detail/* - this would then become http://www.example.com/detail/name_of_post

Something like that perhaps?

Also if there was any way of taking the * part and converting from underscores to dashes and vice-versa just in case people want to change those over too.

Please tell me if I am way off base on this one because as I said earlier I’m very very new to all the re-direct stuff so this may not even be possible.

Again great work on this though grin

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 30 May 2008 09:51 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  569
Joined  07-22-2004

Victor, this is an awesome module and I believe the need for
proper redirection is greater than most people realize.

I would love to see it (like how we discussed) output all
the records to an .htaccess file for both IIS (isapi_rewrite)
and Apache (mod_rewrite).

I would feel more comfortable having the redirect stuff happen
on the server before EE kicks in, and this would be a great
interface to setting the redirection up!

Another neat trick would be if one could automatically create
an htaccess file from a list of all weblog entries in X weblog,
X category, X status, X author etc.
I imagine a filter like the edit page search box.
Now that I think of it, it would need to support Pages too,
should this FR tickle your fancy..

That way one could prepare redirections before a site migration
with just a few clicks.

Great work Victor,
I’m already looking forward to your next piece of code!


best
Andy

 Signature 

ExpressionEngineer - custom solutions for EE

I EE

Profile
 
 
Posted: 31 May 2008 10:17 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  436
Joined  02-02-2006

This is a great module idea! Definitely something that is needed. I will try this out and hope to make part of our regular EE toolset. Thanks!


(Ignore the blank message above. I was accidentally logged in with a work account when I posted. smile) Mod: Removed for you conveniece :=)

 Signature 

Learn EE step-by-step with the ExpressionEngine Screencasts

Ryan Irelan

Profile
 
 
Posted: 04 June 2008 10:15 AM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  174
Joined  03-31-2002

Hi Victor -

Great extension!

I’m using it - and it works great - but I am getting this error messgae when I add a redirect:

Notice: Undefined variable: exact in /home/path/to/modules/rewrite/mcp.rewrite.php on line 643

As I say, it still works OK, but I thought I would mention this.

 Signature 

Les McKeown, President & CEO
Predictable Success®

Profile
 
 
Posted: 15 June 2008 03:58 PM   [ Ignore ]   [ # 9 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  292
Joined  03-21-2005

I tried uploading these files to my site to try it out. Not only could I not enable the extension/module, when I tried removing the files, my site failed and I get this error:

Error Message
Unable to load the following extension file:
ext.rewrite_ext.php

When I reupload the file it can’t find, I get this error:

MySQL ERROR:
Error Number: 1146
Description: Table ‘eh****a.exp_rewrite’ doesn’t exist
Query: SELECT * FROM exp_rewrite WHERE url = ‘http://www.website.com/’ LIMIT 1

If there’s anyone out there on a Sunday afternoon who could help, please do.

 Signature 

VENN ~ Web Development : Web Content Management

Profile
 
 
Posted: 15 June 2008 04:16 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  716
Joined  07-02-2007

Hey,

This happens in some situations, where the order of steps can mess things up. I am rewriting some code as we speak to automate a lot of it, so no error’s on the user side can happen.

This is how you fix it:
Head to phpmyadmin and execute the following query:

UPDATE exp_extensions SET enabled = 'n' WHERE class = 'Rewrite_ext'

If you don’t know what phpmyadmin is:
-Login to your site’s ftp
-Go to your system folder and open config.php
-Change: $conf[‘allow_extensions’] = “y”; TO $conf[‘allow_extensions’] = “n”;
-Login to your CP and head over to: Admin > Utilities > SQL Manager > Database Query Form
-Execute the above query.
-Change the value of the config.php to “y” again

Hope that helps

 Signature 

Truly ExpressionEngine


Fielder Module ( Mass Custom Fields )
Super Cache (Cache heavy tag output)
reCAPTCHA Extension
Rewrite Module


See all my EE Addons (8)

Profile
 
 
Posted: 15 June 2008 04:30 PM   [ Ignore ]   [ # 11 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  292
Joined  03-21-2005

I was in phpmyadmin looking at the extensions table the moment this came in. Thanks for being there at such a ridiculous time on a Sunday.

Site’s back.

You mentioned I got the order of things messed up. You’re probably right. So, if I was going to try this again, would I enable the module FIRST, and THEN the extension?

ADDED: I answered my own question. Install module first, enable extension second.

 Signature 

VENN ~ Web Development : Web Content Management

Profile
 
 
Posted: 15 June 2008 04:40 PM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  716
Joined  07-02-2007
Kevin | Venn - 15 June 2008 04:30 PM

I was in phpmyadmin looking at the extensions table the moment this came in. Thanks for being there at such a ridiculous time on a Sunday.

Site’s back.

You mentioned I got the order of things messed up. You’re probably right. So, if I was going to try this again, would I enable the module FIRST, and THEN the extension?

Yes sir,
Module first. Then Extension.

In the next version i will make this happen automatically.

 Signature 

Truly ExpressionEngine


Fielder Module ( Mass Custom Fields )
Super Cache (Cache heavy tag output)
reCAPTCHA Extension
Rewrite Module


See all my EE Addons (8)

Profile
 
 
Posted: 15 June 2008 04:55 PM   [ Ignore ]   [ # 13 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  292
Joined  03-21-2005

Beautiful. Kinda like Dutch football lately. Go Orange!

Thanks for writing this, even if my first try installing it did make me need a change of underpants.

As Les mentions, there is this message:

Notice: Undefined variable: exact in /home/path/to/modules/rewrite/mcp.rewrite.php on line 643

I’m sure you’ll have it sorted.

 Signature 

VENN ~ Web Development : Web Content Management

Profile
 
 
Posted: 26 June 2008 08:53 AM   [ Ignore ]   [ # 14 ]  
Grad Student
Avatar
Rank
Total Posts:  86
Joined  07-04-2007

Hi Victor,

Thanks for this great module, I’ve been looking for ages for a good way of implementing SEO friendly 301’s.

One minor enhancement request would be to ensure that it works automatically on urls that have a trailing slash as well as those that don’t:

www.domain.com/widgets/about_us
and
www.domain.com/widgets/about_us/

James

Profile
 
 
Posted: 14 July 2008 04:42 PM   [ Ignore ]   [ # 15 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  144
Joined  07-21-2006

Hi Victor

I’m getting:

Notice: Undefined variable: exact in /home/mysite/public_html/mysite/system/modules/rewrite/mcp.rewrite.php on line 643

Could this be a MSM compatibility problem or a field problem?

 Signature 

// matthanson.net
// twitter

Profile
 
 
Posted: 14 July 2008 08:14 PM   [ Ignore ]   [ # 16 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  716
Joined  07-02-2007

It’s a Module error.

Rewriting this module is in my to-do list, hopefully this weekend.

-Victor

 Signature 

Truly ExpressionEngine


Fielder Module ( Mass Custom Fields )
Super Cache (Cache heavy tag output)
reCAPTCHA Extension
Rewrite Module


See all my EE Addons (8)

Profile
 
 
Posted: 15 July 2008 01:59 AM   [ Ignore ]   [ # 17 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  144
Joined  07-21-2006

thanks for the fast reply victor. i’ll keep my eyes peeled for the rewrite smile

 Signature 

// matthanson.net
// twitter

Profile
 
 
Posted: 06 August 2008 08:38 AM   [ Ignore ]   [ # 18 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  189
Joined  10-17-2007

Is this module safe to run on a production site at the moment Victor?

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64907 Total Logged-in Users: 38
Total Topics: 81849 Total Anonymous Users: 38
Total Replies: 440051 Total Guests: 223
Total Posts: 521900    
Members ( View Memberlist )