Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
URI Redirect Plugin
#1
Support forum for the URI redirect plugin.

Version 0.2.1 Changes:
  • Added a check to make sure curl installed before trying to use it to do version checking
  • I was assuming fancy URLs selected, that has been changed


Version 0.2 Changes:
  • The need to set a subfolder has been removed, installing the plugin reduced to just copying the plugin file
  • Use of short tags has been removed
  • In general, now following the GetSimple core coding guidelines
  • Select drop box now sorting by page title
  • When editing redirects the plugin will now check if a new version available

Version 0.1 - Initial
I wrote this plugin because I am re-doing an old site of mine using Get Simple and still have a few pages that get some heavy referring traffic that I didn't want to loose. This plugin allows you to take the old path to a page slap it in and select a new page to redirect to.
Reply
#2
Awesome!!

Thank you for your contribution. This will save me a lot of work!!
Reply
#3
That's a really helpful contribution! Thanks for sharing it!
Reply
#4
This does not seem to be working for me, fresh installation getsimple 3.0..

Loading the uri I set to redirect goes to "We are sorry, but the page you are looking for does not exist."
Reply
#5
Thanks! Very usefull. No more .htaccess editing!
Reply
#6
Very interesting plugin (one that GetSimple was missing).

But... doesn't work for me. Same as mikeh.

BTW you are using php shot tags ("<?=") in the backend page. They're not recommended for general use.
Reply
#7
Carlos Wrote:BTW you are using php shot tags ("<?=") in the backend page. They're not recommended for general use.

Thanks Carlos for this warning!

To confirm Carlos, with that short tags we will run into problems

1) this option is not activated in php.ini at many hosts, if plugins use it, it should be activated in .htaccess:
Code:
php_flag short_open_tag on
,

but:

2) this use is absolute critical in connection with php + xml.

See here: from http://php.net/manual/en/ini.core.php

Quote:Tells PHP whether the short form (<? ?>) of PHP's open tag should be allowed. If you want to use PHP in combination with XML, you can disable this option in order to use <?xml ?> inline. Otherwise, you can print it with PHP, for example: <?php echo '<?xml version="1.0"?>'; ?>. Also, if disabled, you must use the long form of the PHP open tag (<?php ?>).

so maybe this should added to the suggestions for plugin-developers?

Never use php short code? We use PHP in conjunction with XML !!!!

maybe short codes are the reason why many users run into problems and get white blank pages?
|--
Die deutsche GetSimple-Webseite: http://www.Get-Simple.de = the german Get-Simple-Website!
Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#8
Connie Wrote:Never use php short code?
I agree with this as a strong recommendation for plugin authors as it makes the code universal.

I would also like to see more encouragement for plugins to conform to the other core coding guidelines (which includes not using PHP short codes). The lack of DocBlock comments, for example, disables some really useful features of modern development tools.
--
Nick.
Reply
#9
Thanks for the feedback! I will remove the short tags, just being lazy. Also when I uploaded the plugin I forgot to set the subfolder to blank. Actually I'd like to remove the subfolder variable, does anyone know if there is a global for it or could I just pull it out of the base url? Also the select box sorting will be better. And going to add support for new version checking.
Reply
#10
Plugin has been updated to version 0.2, changes include:
  • The need to set a subfolder has been removed, installing the plugin reduced to just copying the plugin file
  • Use of short tags has been removed
  • In general, now following the GetSimple core coding guidelines
  • Select drop box now sorting by page title
  • When editing redirects the plugin will now check if a new version available

If the plugin wasn't working for you, please try it again and let me know if you are still seeing issues.
Reply
#11
@NathanF

0.2 still doesn't work for me.
Admin panel ok, but the redirects are not being done, just get the "Oops! ..."

I haven't tested this in the root of a domain, only in subdirs.

Just in case I enabled debug mode, but I get no errors.

BTW, in my localhost test server (XAMPP) curl is not enabled, and your plugin "broke" my site. I had to patch it by inserting:
Code:
return;
in line 245 (function checkVersion).

Is curl really needed?
Reply
#12
Thank you Carlos. I've added a check to see if curl is installed before using it. Would you suggest file_get_contents() instead of curl or something else?

I realized that I was pretty much assuming everyone would have Fancy URLs checked. Realizing that was a mistake, I changed that so it should work regardless.

Thank you again for the feedback.
Reply
#13
NathanF Wrote:Thank you Carlos. I've added a check to see if curl is installed before using it. Would you suggest file_get_contents() instead of curl or something else?

I'd suggest checking if curl is available.
I might do it with
Code:
if (function_exists('curl_version'))  ...
instead of try ... catch

I'm no PHP expert, I don't know why, but I get this:
Quote:Fatal error: Call to undefined function curl_version() in D:\xampp\htdocs\gs300\plugins\URIRedirect.php on line 240
if I don't patch you plugin. (This is in my localhost test server, with no curl installed)

NathanF Wrote:I realized that I was pretty much assuming everyone would have Fancy URLs checked. Realizing that was a mistake, I changed that so it should work regardless.

I'm afraid that 0.2.1 still doesn't work for me. Just tested it in a fresh GS 3.0 install in the root of a public domain, and I still get the Oops... 404 page with redirected pages (both with and without fancy permalinks enabled).

PS Some comments: I have not examined your plugin, but taking a quick look at it I see much code in the do_uri_redirect function. It might be easier if you used GetSimple's core find_url function. Another thing is that I might try to use the 'error-404' hook instead of 'index-pretemplate' (unless you want to allow redirection of existing pages).

Edit: although maybe it would be interesting to have the option to redirect existing pages...
Reply
#14
Has anyone tested this plugin?
Reply
#15
Carlos Wrote:Has anyone tested this plugin?

I'm not a qualified GS tester in the guru sense of the word, but I am a novice GS user and have tried the URI redirect plugin and I still can't get it to work (only see the oops page).

Nor can I get redirects working by editing .htaccess directly (as I'm not up on apache syntax) - so even posting a 'how-to redirect pretty urls in GS 3.0' would be really handy!

eg I would like:

Code:
www.mydomain.com/old-url/
to 301 redirect to
Code:
www.mydomain.com/new-url/

Thanks!
Reply
#16
as this is no GS specific topic, I list some URLs which are easily found using a websearch:

http://makeitrank.com/10-htaccess-hacks-...hould-know (especially #3: 3. Implement a 301 Redirect with htaccess)

or read this one:

http://anthosting.co.za/htaccess.html


this is also a great tutorial, where the tipps are categorized:
http://perishablepress.com/press/2006/01...ss-tricks/

the syntax is always:
Code:
Redirect /olddirectory/oldfile.html http://yoursite.com/newdirectory/newfile.html
|--
Die deutsche GetSimple-Webseite: http://www.Get-Simple.de = the german Get-Simple-Website!
Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#17
@bigbanghq

Several examples for .htaccess that may work for you, in this thread:
http://get-simple.info/forum/topic/1552/...direction/

PS A pity this plugin doesn't work... GS should have a working redirection plugin. If I have the time I'll give it a try (but not in the near future, so if someone can....)
Reply
#18
Carlos Wrote:GS should have a working redirection plugin

Thanks Connie and Carlos - I turned to the plug-in option after a fair bit of experimenting with .htaccess examples I'd Googled (none of which I managed to get to work). I will have another try using your suggestions.

I think plugins for .htaccess-related tasks would be a great addition to making GS 'less-techy'-friendly. There are lots of potential users out there who may be familiar with front-end design but get snagged on what are (to the uninitiated) time-consuming tweaks (because you have to have enough understanding of unfamiliar syntax).

In terms of end-users, a plugin would also mean a non-techy can rename a page (say in response to SEO, or simply an error) without fear of 'breaking' the site, and without the cost of involving their webmaster.

I think the other piece of this is custom (or even better, intelligent) 404s - even on small sites, quickly signposting a visitor positively helps a lot - "did you mean x?" is much better than just "dead end".

Thanks,

Adrian
Reply
#19
PS - despite 'paying attention the placement of things', I can't hit on the right string to make it work - I have the same result as gimx gets, ie:

Code:
http://www.domain.tld/old-slug becomes http://www.domain.tld/new-slug?id=old-slug

How do I lose the id= part? (S)he solved it, but unfortunately didn't post how!

It's this internal GS page structure (with pretty urls) - not shifting domains, or renaming files ending .htm(l) - which will be the most common change I need to make.

Thanks again.

A
Reply
#20
You are using the paginate class on your URIs table, but you don't provide the necessary DIV to hold the paging links that jQuery renders. That means that currently one can see only the first 14 URIs that were created, and the rest are hidden. According to the existing GetSimple pages, you need to add this after your table:

Code:
<?php if(defined('GSPAGER')) { ?><div id="page_counter" class="qc_pager"></div><?php } ?>

Or, remove the paginate class from the table.
Get-Simple Plugins: Nested Menus
Firefox Plugins: Clean and Close, Focus Last Tab
Reply
#21
This plugin looks damaged, because it doesn't respect custom page suffix and it isn't redirecting to the "fail-back" language which I've set for my pages, whenever no language has been provided.

I hope somebody can fix this, because this plugin could be very useful for a lot of people!
Reply
#22
Question 
Problem
"http://www.domain.tld/old-slug becomes http://www.domain.tld/new-slug?id=old-slug"
still not solved?
Reply
#23
Hi!

Thank you for your plugin!

But I have a problem with using it.
Redirection works, but unfortunatelly it returns new Location as https instead of http.

I found following condition in your plugin:


PHP Code:
   if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1') {
 
                            $protocol 'http://';
 
                    } else {
 
                           $protocol 'https://';
 
                    
so I went to check my request with firebug and it is good:
GET /cms/test-redirect HTTP/1.1
...
but the plugin responds me
...
Location: https://my-host.com/cms/new_location/

Does anyone had such problem?
Tell me please, what is the problem could be.


UPD
I check my request in webserver log and it is strange, but it is different for the same request:
GET /cms/test-redirect HTTP/1.0

Tell me please, how this is possible?

And what is the reason all requests exept HTTP/1.1 redirect to https in the plugin?




GetSimple version 3.3.3
PHP 5.2.17
Apache/1.3.42 (FreeBSD)
Reply
#24
(2015-07-20, 18:15:31)alexeyGL Wrote: Hi!

Thank you for your plugin!

But I have a problem with using it.
Redirection works, but unfortunatelly it returns new Location as https instead of http.

I found following condition in your plugin:




PHP Code:
   if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1') {
 
                            $protocol 'http://';
 
                    } else {
 
                           $protocol 'https://';
 
                    
so I went to check my request with firebug and it is good:
GET /cms/test-redirect HTTP/1.1
...
but the plugin responds me
...
Location: https://my-host.com/cms/new_location/

Does anyone had such problem?
Tell me please, what is the problem could be.


UPD
I check my request in webserver log and it is strange, but it is different for the same request:
GET /cms/test-redirect HTTP/1.0

Tell me please, how this is possible?

And what is the reason all requests exept HTTP/1.1 redirect to https in the plugin?




GetSimple version 3.3.3
PHP 5.2.17
Apache/1.3.42 (FreeBSD)

I found the reason of such behaviour. This is because of nginx.
Some versions of nginx connect with apache via http/1.1
This is not a new problem as well as I see

CLIENT <---- (HTTP 1.1) ----> NGINX <----- (HTTP 1.0) ----> SERVER


So, my question about plugin is still actual
What is the reason all requests exept HTTP/1.1 redirect to https in the plugin? Should http/1.0 be added to condition?
Reply
#25
I have made some much-needed updates to this plugin. Does anyone know the process of adding me as a maintainer of this plugin so that I can update the code in the repository?

Some improvements that I've made:
- Fixed a typo that cause this plugin not to work for those with GetSimple installed in a subfolder (this is why many people in this thread were saying the plugin wasn't working for them)
- Added the ability to redirect to an external URL
- Improved the settings page by listing redirect counts and last redirected date
- Addressing alexeyGL's concerns above, the code has been changed to look at $_SERVER['HTTPS'] instead of $_SERVER['SERVER_PROTOCOL']
Reply




Users browsing this thread: 1 Guest(s)