Coder Social home page Coder Social logo

dolphiq / craft-plugin-redirect Goto Github PK

View Code? Open in Web Editor NEW
54.0 5.0 30.0 913 KB

Craft 3 redirect plugin provides an easy way to enter and maintain 301 and 302 redirects and 404 pages. The plugin provides a clear user interface for admin and non-admin users.

License: MIT License

PHP 85.50% HTML 3.88% Twig 10.63%
redirect-plugin craft craft3 301-redirect seo seo-optimization plugin craftcms-plugin

craft-plugin-redirect's People

Contributors

24hoursmedia-craftcms avatar boscho87 avatar brandonkelly avatar dolphiq-allard avatar dwheeldo avatar helgesverre avatar iparr avatar johanzandstra avatar joshc96 avatar kringkaste avatar leigh-ochsner avatar mosnar avatar ohlincik avatar rickdegraaf-dq avatar rjhallsted avatar robwouters avatar sergeifilippov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

craft-plugin-redirect's Issues

Using global variables in redirect rules

We have 130 sites (city portals) in a multi-site configuration.
We did some URL changes to them and need to find a simple way of redirecting those.
We have parts of URLs for cities saved as Global Variables.

Can we use Global Variables in the plugin? (Tried with parameters but it didn't work.)
That would enable us to only have 1 redirect for something, instead of 130.

Thanks!

Database Exception when adding redirect

Hi, it's not possible to add new redirects after adding hitCount support.

hitCount field is NOT NULL so it probably should have default value of 0.

The SQL being executed was: INSERT INTO `dolphiq_redirects` (`sourceUrl`, `destinationUrl`, `statusCode`, `dateCreated`, `uid`, `dateUpdated`) VALUES ('legal', 'legal/privacy', '302', '2017-07-07 09:45:19', '207a0731-eefe-451e-a15d-ee10270f2ca2', '2017-07-07 09:45:19')
Error Info: Array
(
    [0] => HY000
    [1] => 1364
    [2] => Field 'hitCount' doesn't have a default value
)
↵
Caused by: PDOException

SQLSTATE[HY000]: General error: 1364 Field 'hitCount' doesn't have a default value

in vendor/yiisoft/yii2/db/Command.php at line 846```

A Few Minor Spelling Issues

Thanks for the plugin. Just spotted a few minor spelling issues.

In the menu:
Temporarily redirects
Should be:
Temporary redirects

In Settings:
This switch activate/de-activate all the entered redirects without removing them.
Should be:
This switch activates/de-activates all the entered redirects without removing them.

Also in Settings:
All the not existing urls are redirected to this page. We also register the missed urls.
Should be:
All the non-existing urls are redirected to this page. We also register the missed urls.

Under Registered catch all urls, if you don't have any registered catch alls:
No registered catch url's exist yet.
Should be
No registered catch urls exist yet.

Catch all fires before static twig templates

If using a static template with no entry (e.g. users/login or anything that is not tied to an actually entry). the catch all system jumps in beforehand breaking access to the static template.

Suggest only firing on a 404 exception event?

Cannot create new redirect

Having similar issue as #58.

I don't see any errors while creating new redirect and I do see badge with "Redirect Save." message after being redirected to /redirect listing page, however I don't see new redirect just created.

In db in dolphiq_redirects table, I do see the entry, however redirect itself does not work

CraftCMS version: 3.1.33
Redirect Plugin version: 1.0.20 (cannot update to latest version due to this issue: #91)
PostgreSQL version: 11.2 and 9.6 (local and remote, having same issue both environments)

Export rules into project.yaml

Hi guys, great plugin, thanks.

Is there any place in the roadmap to export the created rules into the project.yaml? It's something that I think could be viewed as config rather than content. Or at least have a checkbox in the plugin settings to say whether it should be in the project.yaml

Cheers
Matt

Installation error

Craft 3.0.0-RC7

When trying to install the plugin on the plugins page in settings the error "Cannot use craft\base\Object because 'Object' is a special class name occurs. See screenshot

screen shot 2018-01-24 at 14 22 34

HitCount Related Postgres issues

There are couple of issues with running plugin on Postgres.

  1. When redirect is added following error occurs:
SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "hitCount" violates not-null constraint DETAIL: Failing row contains (1, null, a, a, 301, null, null, 2017-08-03 16:33:19, 2017-08-03 16:33:19, null, e5f0ac1a-913f-4410-be29-49965fa54a7e). The SQL being executed was: INSERT INTO "dolphiq_redirects" ("sourceUrl", "destinationUrl", "statusCode", "dateCreated", "uid", "dateUpdated") VALUES ('a', 'a', '301', '2017-08-03 16:33:19', 'e5f0ac1a-913f-4410-be29-49965fa54a7e', '2017-08-03 16:33:19') RETURNING "id"

This can be solved by following sql:

ALTER TABLE "public"."dolphiq_redirects"
  ALTER COLUMN "hitCount" DROP NOT NULL,
  ALTER COLUMN "hitCount" SET DEFAULT '0';
  1. When redirect is followed, following error occurs:
SQLSTATE[42703]: Undefined column: 7 ERROR: column "hitcount" does not exist LINE 1: ..."dolphiq_redirects" SET "hitAt"=now(), "hitCount"=hitCount +...
                                          ^
HINT: Perhaps you meant to reference the column "dolphiq_redirects.hitCount". The SQL being executed was: UPDATE "dolphiq_redirects" SET "hitAt"=now(), "hitCount"=hitCount + 1, "dateUpdated"='2017-08-03 16:14:28' WHERE "id"=3

This can be solved by quoting hitCount in the query, like this: 'hitCount'=>new \yii\db\Expression('"hitCount" + 1'),

Can you please add abovementioned fixes to the following release

Can't create redirects, not taking Site into account

When a url is hit with a page that doesn't it exist it is caught in the Registered catch all urls section.

I then go to that particular entry and update the destination url which should then add a redirect entry. However it is adding the entry under the wrong site and removing the starting /.

I thought I could just add a new redirect manually for the time being but even that is is adding the entry under the wrong site and removing the starting /.

Basically it does not seem to be taking into account the Site, which means now I can't create any redirect entries what so ever

Redirects not being shown in the index list, no buttons/links work.

Hey, i have installed the latest version ( at the time of writing) of this plugin on a Craft v3.0.20 install, our site is setup with the multisite feature, and have 2 sites with 2 different locales

PHP Version: 7.1.16

I am able to click the "create redirect" button and click the save button, however it does not seem like anything is created, nor do the index page list any redirects that have been saved, the filters in the sidebar (permanent/temporary) are not clickable.

Here is a video of what is happening:

https://screencast-o-matic.com/watch/cFjoQTqIqo

No redirects are working.

I may be missing something here, but I can't get any simple redirect to work. Something like this:

/category/page to /category is not working..

Craft 3 - Redirect from a URL that resolves not working

Trying to redirect from a parent page to first child. Both urls resolve. The redirect does not work.
But, if the original source does not exist, the redirect works. Is this the intended functionality? In other words, must the source URL not exist within the site?

Plugin won't install after last update

We're seeing any where the plugin is not enabled after we build our Craft site. This started after the last update to the plugin. When trying to enable it we get the following error:

db_1        | 2019-04-19 22:31:43.820 UTC [201] ERROR:  relation "dp_dolphiq_redirects" already exists
db_1        | 2019-04-19 22:31:43.820 UTC [201] STATEMENT:  CREATE TABLE "dp_dolphiq_redirects" (
db_1        | 		"id" serial NOT NULL PRIMARY KEY,
db_1        | 		"type" varchar(8) NOT NULL DEFAULT 'static',
db_1        | 		"sourceUrl" varchar(255),
db_1        | 		"destinationUrl" varchar(255),
db_1        | 		"statusCode" varchar(255),
db_1        | 		"hitCount" integer NOT NULL DEFAULT 0,
db_1        | 		"hitAt" timestamp(0),
db_1        | 		"dateCreated" timestamp(0) NOT NULL,
db_1        | 		"dateUpdated" timestamp(0) NOT NULL,
db_1        | 		"dateDeleted" timestamp(0) NULL DEFAULT NULL,
db_1        | 		"uid" char(36) NOT NULL DEFAULT '0'
db_1        | 	)
db_1        | 2019-04-19 22:31:43.828 UTC [201] ERROR:  current transaction is aborted, commands ignored until end of transaction block

If we lock in the version of the plugin to v1.0.20 everything remains fine, and the plugin is enabled once we've built the site, and the redirects remain intact.

Putting a # into the Source URL Breaks Site

Ran into this today when a user added a Source URL with an anchor in it. I'd guess somewhere internally '#' is being used to delimit regex expressions for UrlRule, and '#' should be escaped.

Latest 1.0.23 migration update fails

Craft Version: 3.0.41.1
Postgres Version: 9.6

Hey I'm updating an existing app that has existing redirect data. Whenever I try to update the plugin to 1.0.23, the migration fails and logs this from my container.

cg-postgres | ERROR:  syntax error at or near "NOT" at character 77
cg-postgres | STATEMENT:  ALTER TABLE "dolphiq_redirects" ALTER COLUMN "sourceUrl" TYPE varchar(1000) NOT NULL DEFAULT ''

I bumped back to 1.0.20 which seems to be the latest stable version for now and everything works as expected. Just thought you would like to know. Thanks

Fresh install: The table does not exist: {{%dolphiq_redirects_catch_all_urls}}

Craft CMS 3.0.0-RC17.1
Redirect plugin for Craft 3 1.0.15

I've just downloaded and installed this plugin and added a few redirects. It works great! I then however went and turned on the "Use a Catch All page template" setting, I've set a 404 template but I keep getting the error The table does not exist: {{%dolphiq_redirects_catch_all_urls}} on the front end.

When I go to "Registered catch all urls" in the CP I get the following message:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sitename_db.dolphiq_redirects_catch_all_urls' doesn't exist
The SQL being executed was: SELECT *
FROM dolphiq_redirects_catch_all_urls
WHERE siteId=1
ORDER BY dateUpdated DESC
LIMIT 100

Error Info: Array
(
[0] => 42S02
[1] => 1146
[2] => Table 'sitename_db.dolphiq_redirects_catch_all_urls' doesn't exist
)

I had a look at the plugin files and can see that this table was added in a migration file as part of a previous update but the Install.php file doesn't reference these tables. My guess would be that the Install file needs to have the new tables in aswell as having them defined in the migrations folder because it looks like it hasn't created the tables when I've installed the plugin. Could this be looked into so I can use this for redirecting to a 404 page please? Thank you.

Class 'verbb\feedme\services\Elements' not found

Description

Hello, an error occured after I update craft3-plugin-redirect and feed me.

Class 'verbb\feedme\services\Elements' not found

This error maybe because of "Craft Acquired FeedMe", so the namescape change from verbb\feedme to craft\feedme

Additional info

  • Plugin version : 1.0.21
  • Craft version: 3.1.23
  • PHP version: 7.3
  • Other plugins & versions (if applicable): feed-me 4.0.0

Broken redirects. Possibly Craft Update Related?

My redirects stopped working out of nowhere. I suspect that something changed in the last Craft update and that's the reason.

If I hit the routes that I have set for redirection nothings happens. No redirect happens.

Twig Error

I get this error:

Twig Syntax Error – Twig_Error_Syntax
A template that extends another one cannot include contents outside Twig blocks. Did you forget to put the contents inside a {% block %} tag?

  1. in /home/vagrant/exterro/exterro.com/craft3/craft/vendor/dolphiq/redirect/src/templates/dashboard.twig

When I edit a redirect, and then try to go back to /admin/settings/redirect.

Number Url causes a UrlRule::pattern Error

Version: 1.0.18 (latest)

Steps to reproduce:

  • Create a new redirect where the sourceUrl is a number. Example: /2018
  • the destinationUrl can be anything
  • 301 redirect (but probably would error either way)

Error:
All routes produce this error, stumbling on the number:

Invalid Configuration – yii\base\InvalidConfigException
UrlRule::pattern must be set.

Possible solution:
Make sure all routes are stored to the database as strings. I think the 2018 is being saved as a number and is therefore being parsed as a pattern instead of an exact route.

Template not found

After installing the plug-in for Craft CMS 3.0.0.RC11 I can't access the redirect and settings page. For both pages I get an 'template not found' exception.
2018-02-21 14_26_40-pagina niet gevonden - crisisconnect

Getting unknown property: dolphiq\redirect\elements\Redirect::plugin

When I clone my production database to my local machine, I've started seeing Getting unknown property: dolphiq\redirect\elements\Redirect::plugin and I can't access the front end of the site until I disable the plugin (I can access the CP). It doesn't happen when I re-install the plugin, so I think this may be something to do with creating a redirect from something to "/", which then gets removed and turned in to "" when you save the redirect.

Let me know if I can give you any more info!

Craft CMS 3.1.26
Redirect plugin for Craft 3 1.0.23

Enabling catch all breaks site

Enabling the catch all feature causes Craft to return a 500 error. Here's the error from the log:

yii\base\ErrorException: Undefined index: sourceUrl in /Users/jdw/Documents/Business/Web Clients/Trajectory/trajectory2/dist/vendor/dolphiq/redirect/src/controllers/RedirectController.php:30 Stack trace: #0 /Users/jdw/Documents/Business/Web Clients/Trajectory/trajectory2/dist/vendor/craftcms/cms/src/web/ErrorHandler.php(84): yii\base\ErrorHandler->handleError(8, 'Undefined index...', '/Users/jdw/Docu...', 30) #1 /Users/jdw/Documents/Business/Web Clients/Trajectory/trajectory2/dist/vendor/dolphiq/redirect/src/controllers/RedirectController.php(30): craft\web\ErrorHandler->handleError(8, 'Undefined index...', '/Users/jdw/Docu...', 30, Array) #2 [internal function]: dolphiq\redirect\controllers\RedirectController->actionIndex() #3 /Users/jdw/Documents/Business/Web Clients/Trajectory/trajectory2/dist/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array) #4 /Users/jdw/Documents/Business/Web Clients/Trajectory/trajectory2/dist/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array) #5 /Users/jdw/Documents/Business/Web Clients/Trajectory/trajectory2/dist/vendor/craftcms/cms/src/web/Controller.php(76): yii\base\Controller->runAction('index', Array) #6 /Users/jdw/Documents/Business/Web Clients/Trajectory/trajectory2/dist/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('index', Array) #7 /Users/jdw/Documents/Business/Web Clients/Trajectory/trajectory2/dist/vendor/craftcms/cms/src/web/Application.php(273): yii\base\Module->runAction('redirect/redire...', Array) #8 /Users/jdw/Documents/Business/Web Clients/Trajectory/trajectory2/dist/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('redirect/redire...', Array) #9 /Users/jdw/Documents/Business/Web Clients/Trajectory/trajectory2/dist/vendor/craftcms/cms/src/web/Application.php(262): yii\web\Application->handleRequest(Object(craft\web\Request)) #10 /Users/jdw/Documents/Business/Web Clients/Trajectory/trajectory2/dist/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request)) #11 /Users/jdw/Documents/Business/Web Clients/Trajectory/trajectory2/dist/web/index.php(21): yii\base\Application->run() #12 {main}

I've found that replacing $redirect['sourceUrl'] on line 181 with a defined string (like 'abc') fixes the issue.

Time stamp is GMT?

I've got my site configured to be my local time zone, Eastern / New York, and most things are fine.

But the time stamps in the "last hit" column are all by four hours. So it looks like it's using GMT rather than the local time zone.

Is this something that needs to be updated in the plugin? Or is there a setting I can add in a config file?

Migration fails for Postgres

image

To fix this issue you need to change line 347 of Redirect.php to this:

->delete('{{%elements_sites}}', '"elementId" = :elementId AND "siteId" != :siteId', [':elementId' => $record->id, ':siteId' => $this->siteId])

Error in CP Section When Loading Redirects

Related to #23

Changes in 1.0.11 now break functionality in the admin. To clarify my issue in #23 - the admin panel worked great with the existing code. I only got an error when the hit count was updated in registerHitById

Feature request: redirect from existing valid URL

#39 outlines that redirect from existing working URL is not expected behaviour. Could the ability to do so be added as a feature request? The case in point - redirecting parent to first (or any child) is my most common use and what I used Reroute in Craft 2 (not upgraded to v3). Content editors need to be able to do this so server rewrite rules are not really accessible for them.

Blacklist or Catch urls without using Catch All

So I enabled catch all so that I could get a list of urls that are not being handled.

Now nothing can visit robots.txt, humans.txt or sitemap.xml.

Is there a way to catch 404s while also letting craft handle just serving up the 404 template if it thinks it is needed.

If that is not something that can happen I would love to have a don't catch blacklist option.

Public facing name setting

It would be nice to have a settings to change the "public facing" name of the plugin (like seomatic does). So instead of the client seeing "Redirect plugin for Craft 3" in the control panel, I could change it to just say "Redirects".

SQL error when opening redirect link (Postgres)

On latest Craft 3 beta, plugin version 1.0.8 when opening the redirect link I get the following error:

SQLSTATE[42703]: Undefined column: 7 ERROR: column "hitcount" does not exist LINE 1: ..."dolphiq_redirects" SET "hitAt"=now(), "hitCount"=hitCount +...
                                                         ^
HINT: Perhaps you meant to reference the column "dolphiq_redirects.hitCount". The SQL being executed was: UPDATE "dolphiq_redirects" SET "hitAt"=now(), "hitCount"=hitCount + 1, "dateUpdated"='2017-11-14 09:26:44' WHERE "id"=37

It can be fixed by the changing Redirects.php line 110 to
'hitCount'=>new \yii\db\Expression('"hitCount" + 1'),

Latest Version not in Packagist

Hello,

https://packagist.org/packages/dolphiq/redirect

Packagist only goes up to version 1.0.9 where as 2.0.7 is the version available in the plugin store.

Our deployment requires all packages updated via composer and we'd like to be on the latest version of your plugin please.

Below is the problem we are getting from composer:

composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package dolphiq/redirect 2.0.7 exists as dolphiq/redirect[1.0.0, 1.0.1, 1.0.10, 1.0.11, 1.0.12, 1.0.13, 1.0.14, 1.0.15, 1.0.16, 1.0.17, 1.0.18, 1.0.2, 1.0.20, 1.0.21, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.8, 1.0.9, dev-development, dev-master] but these are rejected by your constraint.

Is there any chance you could update/sync the versions to packagist please.

Ability to set exact matching

I have a case where the matching needs to be stricter than currently possible (I looked over the docs and could not see anything that would help).

Scenario:

Website has the following page /local-mall-info.

When I setup a redirect for the uri mall-info the redirection redirects to mall-info with partial content from local-mall-info page.

Weird.

Redirects are case sensitive, but can't add different case options

I need to set up a redirect for both a lowercase and mixed-case version of a URL (/bridgetown and /Bridgetown). Redirect won't let me set up two, but I get a 404 error on the capital B version. How can I get around this? I believe an older version wasn't case sensitive and redirected any case to the existing redirect.

FR: CSV Import/Export?

I plan on using this plugin on a future project. It would be great to be able to import/export redirects via a .csv file.

Doesn't redirect when Source URL contains query string

I'm setting up the 301 redirects for a site that previously used a URL structure like 'index.asp?PageID=26'.

Every unique PageID param should redirect to a different page on the site. e.g.

'index.asp?PageID=26' => 'about-us/jobs'

None of these redirects are currently working.

Is there an alternative way of setting up these redirects to get it working as needed?

Craft CMS: 3.0.1
Redirect plugin for Craft 3: 1.0.15

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.